Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MAINT: Enable linting with ruff E501 #29250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

eendebakpt
Copy link
Contributor

Part of #28947

Copy link
Member

@jorenham jorenham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I picked some nits; hope you don't mind.

Comment on lines +297 to +298
@pytest.mark.skipif(sys.maxsize < 2**32,
reason="only problematic on 64bit platforms")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks a bit weird; so how about

Suggested change
@pytest.mark.skipif(sys.maxsize < 2**32,
reason="only problematic on 64bit platforms")
@pytest.mark.skipif(
sys.maxsize < 2**32,
reason="only problematic on 64bit platforms"
)

or

Suggested change
@pytest.mark.skipif(sys.maxsize < 2**32,
reason="only problematic on 64bit platforms")
@pytest.mark.skipif(sys.maxsize < 2**32,
reason="only problematic on 64bit platforms")

Comment on lines +384 to +385
@pytest.mark.skipif(IS_PYPY,
reason="PYPY handles sq_concat, nb_add differently than cpython")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@pytest.mark.skipif(IS_PYPY,
reason="PYPY handles sq_concat, nb_add differently than cpython")
@pytest.mark.skipif(
IS_PYPY,
reason="PYPY handles sq_concat, nb_add differently than cpython"
)

or

Suggested change
@pytest.mark.skipif(IS_PYPY,
reason="PYPY handles sq_concat, nb_add differently than cpython")
@pytest.mark.skipif(IS_PYPY,
reason="PYPY handles sq_concat, nb_add differently than cpython")

(if that even fits)

@@ -309,7 +310,7 @@ def test_basic(self):
def test_order(self):
# It turns out that people rely on np.copy() preserving order by
# default; changing this broke scikit-learn:
# github.com/scikit-learn/scikit-learn/commit/7842748cf777412c506a8c0ed28090711d3a3783
# github.com/scikit-learn/scikit-learn/commit/7842748cf777412c506a8c0ed28090711d3a3783 # noqa: E501
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also works:

Suggested change
# github.com/scikit-learn/scikit-learn/commit/7842748cf777412c506a8c0ed28090711d3a3783 # noqa: E501
# github.com/scikit-learn/scikit-learn/commit/7842748

Comment on lines +3148 to +3150
assert_equal(np.interp(0.5, [-inf, +inf], sc([ 0, 10])), sc(nan))
assert_equal(np.interp(0.5, [ 0, 1], sc([-inf, +inf])), sc(nan))
assert_equal(np.interp(0.5, [ 0, 1], sc([+inf, -inf])), sc(nan))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert_equal(np.interp(0.5, [-inf, +inf], sc([ 0, 10])), sc(nan))
assert_equal(np.interp(0.5, [ 0, 1], sc([-inf, +inf])), sc(nan))
assert_equal(np.interp(0.5, [ 0, 1], sc([+inf, -inf])), sc(nan))
assert_equal(np.interp(0.5, [-inf, +inf], sc([ 0, 10])), sc(nan))
assert_equal(np.interp(0.5, [ 0, 1], sc([-inf, +inf])), sc(nan))
assert_equal(np.interp(0.5, [ 0, 1], sc([+inf, -inf])), sc(nan))

Comment on lines +3159 to +3166
assert_equal(np.interp(0.5, [-inf, 1], sc([-inf, 10])), sc(nan))
assert_equal(np.interp(0.5, [-inf, 1], sc([+inf, 10])), sc(nan))
assert_equal(np.interp(0.5, [-inf, 1], sc([ 0, -inf])), sc(nan))
assert_equal(np.interp(0.5, [-inf, 1], sc([ 0, +inf])), sc(nan))
assert_equal(np.interp(0.5, [ 0, +inf], sc([-inf, 10])), sc(nan))
assert_equal(np.interp(0.5, [ 0, +inf], sc([+inf, 10])), sc(nan))
assert_equal(np.interp(0.5, [ 0, +inf], sc([ 0, -inf])), sc(nan))
assert_equal(np.interp(0.5, [ 0, +inf], sc([ 0, +inf])), sc(nan))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert_equal(np.interp(0.5, [-inf, 1], sc([-inf, 10])), sc(nan))
assert_equal(np.interp(0.5, [-inf, 1], sc([+inf, 10])), sc(nan))
assert_equal(np.interp(0.5, [-inf, 1], sc([ 0, -inf])), sc(nan))
assert_equal(np.interp(0.5, [-inf, 1], sc([ 0, +inf])), sc(nan))
assert_equal(np.interp(0.5, [ 0, +inf], sc([-inf, 10])), sc(nan))
assert_equal(np.interp(0.5, [ 0, +inf], sc([+inf, 10])), sc(nan))
assert_equal(np.interp(0.5, [ 0, +inf], sc([ 0, -inf])), sc(nan))
assert_equal(np.interp(0.5, [ 0, +inf], sc([ 0, +inf])), sc(nan))
assert_equal(np.interp(0.5, [-inf, 1], sc([-inf, 10])), sc(nan))
assert_equal(np.interp(0.5, [-inf, 1], sc([+inf, 10])), sc(nan))
assert_equal(np.interp(0.5, [-inf, 1], sc([ 0, -inf])), sc(nan))
assert_equal(np.interp(0.5, [-inf, 1], sc([ 0, +inf])), sc(nan))
assert_equal(np.interp(0.5, [ 0, +inf], sc([-inf, 10])), sc(nan))
assert_equal(np.interp(0.5, [ 0, +inf], sc([+inf, 10])), sc(nan))
assert_equal(np.interp(0.5, [ 0, +inf], sc([ 0, -inf])), sc(nan))
assert_equal(np.interp(0.5, [ 0, +inf], sc([ 0, +inf])), sc(nan))

@@ -249,8 +254,8 @@ def test_complex(self):
def test_integ_coeffs(self):
p = np.poly1d([3, 2, 1])
p2 = p.integ(3, k=[9, 7, 6])
assert_(
(p2.coeffs == [1 / 4. / 5., 1 / 3. / 4., 1 / 2. / 3., 9 / 1. / 2., 7, 6]).all())
expected = [1 / 4. / 5., 1 / 3. / 4., 1 / 2. / 3., 9 / 1. / 2., 7, 6]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess these python 2 remnants aren't needed anymore

Suggested change
expected = [1 / 4. / 5., 1 / 3. / 4., 1 / 2. / 3., 9 / 1. / 2., 7, 6]
expected = [1 / 4 / 5, 1 / 3 / 4, 1 / 2 / 3, 9 / 1 / 2, 7, 6]

assert_(
(p2.coeffs == [1 / 4. / 5., 1 / 3. / 4., 1 / 2. / 3., 9 / 1. / 2., 7, 6]).all())
expected = [1 / 4. / 5., 1 / 3. / 4., 1 / 2. / 3., 9 / 1. / 2., 7, 6]
assert_( (p2.coeffs == expected).all())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert_( (p2.coeffs == expected).all())
assert_((p2.coeffs == expected).all())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants