8000 Merge pull request #28756 from DimitriPapadopoulos/PLW · numpy/numpy@b76bb23 · GitHub
[go: up one dir, main page]

Skip to content

Commit b76bb23

Browse files
authored
Merge pull request #28756 from DimitriPapadopoulos/PLW
MNT: Apply assorted ruff/Pylint Warning rules (PLW)
2 parents b59d8ce + 26cb46d commit b76bb23

File tree

9 files changed

+13
-15
lines changed

9 files changed

+13
-15
lines changed

doc/source/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ def setup(app):
235235
html_favicon = '_static/favicon/favicon.ico'
236236

237237
# Set up the version switcher. The versions.json is stored in the doc repo.
238-
if os.environ.get('CIRCLE_JOB', False) and \
239-
os.environ.get('CIRCLE_BRANCH', '') != 'main':
238+
if os.environ.get('CIRCLE_JOB') and os.environ['CIRCLE_BRANCH'] != 'main':
240239
# For PR, name is set to its ref
241240
switcher_version = os.environ['CIRCLE_BRANCH']
242241
elif ".dev" in version:

numpy/_core/tests/test_arrayprint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ def _format_function(x):
245245
"[. o O]")
246246
assert_(np.array2string(x, formatter={'all': lambda x: f"{x:.4f}"}) ==
247247
"[0.0000 1.0000 2.0000]")
248-
assert_equal(np.array2string(x, formatter={'int': lambda x: hex(x)}),
248+
assert_equal(np.array2string(x, formatter={'int': hex}),
249249
x_hex)
250-
assert_equal(np.array2string(x, formatter={'int': lambda x: oct(x)}),
250+
assert_equal(np.array2string(x, formatter={'int': oct}),
251251
x_oct)
252252

253253
x = np.arange(3.)

numpy/_core/tests/test_deprecations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class TestCtypesGetter(_DeprecationTestCase):
220220
)
221221
def test_deprecated(self, name: str) -> None:
222222
func = getattr(self.ctypes, name)
223-
self.assert_deprecated(lambda: func())
223+
self.assert_deprecated(func)
224224

225225
@pytest.mark.parametrize(
226226
"name", ["data", "shape", "strides", "_as_parameter_"]
@@ -361,7 +361,7 @@ def test_lib_functions_deprecation_call(self):
361361
self.assert_deprecated(lambda: recfromtxt(data_gen(), **kwargs))
362362

363363
self.assert_deprecated(lambda: disp("test"))
364-
self.assert_deprecated(lambda: get_array_wrap())
364+
self.assert_deprecated(get_array_wrap)
365365
self.assert_deprecated(lambda: maximum_sctype(int))
366366

367367
self.assert_deprecated(lambda: in1d([1], [1]))

numpy/_core/tests/test_multiarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3743,8 +3743,8 @@ def test_conjugate(self):
37433743
assert_equal(ac, np.conjugate(a))
37443744

37453745
a = np.array([1 - 1j, 1, 2.0, 'f'], object)
3746-
assert_raises(TypeError, lambda: a.conj())
3747-
assert_raises(TypeError, lambda: a.conjugate())
3746+
assert_raises(TypeError, a.conj)
3747+
assert_raises(TypeError, a.conjugate)
37483748

37493749
def test_conjugate_out(self):
37503750
# Minimal test for the out argument being passed on correctly

numpy/f2py/tests/test_callback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def check_function(self, name):
6161
assert r == 6
6262
r = t(lambda a: 5 + a, fun_extra_args=(7, ))
6363
assert r == 12
64-
r = t(lambda a: math.degrees(a), fun_extra_args=(math.pi, ))
64+
r = t(math.degrees, fun_extra_args=(math.pi, ))
6565
assert r == 180
6666
r = t(math.degrees, fun_extra_args=(math.pi, ))
6767
assert r == 180

numpy/lib/_function_base_impl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
# --- HYNDMAN and FAN METHODS
6868
# Discrete methods
6969
'inverted_cdf': {
70-
'get_virtual_index': lambda n, quantiles: _inverted_cdf(n, quantiles),
70+
'get_virtual_index': lambda n, quantiles: _inverted_cdf(n, quantiles), # noqa: PLW0108
7171
'fix_gamma': None, # should never be called
7272
},
7373
'averaged_inverted_cdf': {
@@ -79,8 +79,7 @@
7979
where=gamma == 0),
8080
},
8181
'closest_observation': {
82-
'get_virtual_index': lambda n, quantiles: _closest_observation(n,
83-
quantiles),
82+
'get_virtual_index': lambda n, quantiles: _closest_observation(n, quantiles), # noqa: PLW0108
8483
'fix_gamma': None, # should never be called
8584
},
8685
# Continuous methods

numpy/lib/tests/test_function_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3057,7 +3057,7 @@ def test_non_finite_behavior_exact_x(self):
30573057
assert_almost_equal(np.interp(x, xp, fp), [1, 2, np.nan, np.nan, 4])
30583058

30593059
@pytest.fixture(params=[
3060-
lambda x: np.float64(x),
3060+
np.float64,
30613061
lambda x: _make_complex(x, 0),
30623062
lambda x: _make_complex(0, x),
30633063
lambda x: _make_complex(x, np.multiply(x, -2))

numpy/testing/_private/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@ def rundocs(filename=None, raise_on_error=True):
13961396

13971397
msg = []
13981398
if raise_on_error:
1399-
out = lambda s: msg.append(s)
1399+
out = msg.append
14001400
else:
14011401
out = None
14021402

numpy/typing/tests/test_typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def run_mypy() -> None:
8484
"""
8585
if (
8686
os.path.isdir(CACHE_DIR)
87-
and bool(os.environ.get("NUMPY_TYPING_TEST_CLEAR_CACHE", True))
87+
and bool(os.environ.get("NUMPY_TYPING_TEST_CLEAR_CACHE", True)) # noqa: PLW1508
8888
):
8989
shutil.rmtree(CACHE_DIR)
9090

0 commit comments

Comments
 (0)
0