Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fc539ff

Browse filesBrowse files
authored
Merge pull request #27973 from DimitriPapadopoulos/PIE
* MAINT: Apply ruff/flake8-pie rule PIE790 PIE790 Unnecessary `pass` statement * MAINT: Apply ruff/flake8-pie rule PIE804 PIE804 Unnecessary `dict` kwargs * MAINT: Apply ruff/flake8-pie rule PIE808 PIE808 Unnecessary `start` argument in `range` * MAINT: Apply ruff/flake8-pie rule PIE810 PIE810 Call `startswith` once with a `tuple`
2 parents 8df89d1 + fb810af commit fc539ff
Copy full SHA for fc539ff

File tree

Expand file treeCollapse file tree

19 files changed

+29
-30
lines changed
Filter options
Expand file treeCollapse file tree

19 files changed

+29
-30
lines changed

‎numpy/_build_utils/tempita/_tempita.py

Copy file name to clipboardExpand all lines: numpy/_build_utils/tempita/_tempita.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __init__(
133133
lineno = caller.f_lineno
134134
if "__file__" in globals:
135135
name = globals["__file__"]
136-
if name.endswith(".pyc") or name.endswith(".pyo"):
136+
if name.endswith((".pyc", ".pyo")):
137137
name = name[:-1]
138138
elif "__name__" in globals:
139139
name = globals["__name__"]
@@ -784,7 +784,7 @@ def parse_expr(tokens, name, context=()):
784784
expr = expr.strip()
785785
if expr.startswith("py:"):
786786
expr = expr[3:].lstrip(" \t")
787-
if expr.startswith("\n") or expr.startswith("\r"):
787+
if expr.startswith(("\n", "\r")):
788788
expr = expr.lstrip("\r\n")
789789
if "\r" in expr:
790790
expr = expr.replace("\r\n", "\n")

‎numpy/_core/numeric.py

Copy file name to clipboardExpand all lines: numpy/_core/numeric.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ def tensordot(a, b, axes=2):
11221122
iter(axes)
11231123
except Exception:
11241124
axes_a = list(range(-axes, 0))
1125-
axes_b = list(range(0, axes))
1125+
axes_b = list(range(axes))
11261126
else:
11271127
axes_a, axes_b = axes
11281128
try:
@@ -1377,7 +1377,7 @@ def rollaxis(a, axis, start=0):
13771377
start -= 1
13781378
if axis == start:
13791379
return a[...]
1380-
axes = list(range(0, n))
1380+
axes = list(range(n))
13811381
axes.remove(axis)
13821382
axes.insert(start, axis)
13831383
return a.transpose(axes)

‎numpy/_core/tests/test_einsum.py

Copy file name to clipboardExpand all lines: numpy/_core/tests/test_einsum.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def __rmul__(self, other):
207207
assert_raises(CustomException, np.einsum, "ij->i", a)
208208

209209
# raised from unbuffered_loop_nop1_ndim3
210-
b = np.array([DestructoBox(i, 100) for i in range(0, 27)],
210+
b = np.array([DestructoBox(i, 100) for i in range(27)],
211211
dtype='object').reshape(3, 3, 3)
212212
assert_raises(CustomException, np.einsum, "i...k->...", b)
213213

‎numpy/_core/tests/test_nditer.py

Copy file name to clipboardExpand all lines: numpy/_core/tests/test_nditer.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,7 @@ def get_params():
23562356

23572357
comp_res = nditer2.operands[-1]
23582358

2359-
for bufsize in range(0, 3**3):
2359+
for bufsize in range(3**3):
23602360
nditer1 = np.nditer([arr, None],
23612361
op_axes=op_axes, flags=flags, op_flags=op_flags,
23622362
buffersize=bufsize, op_dtypes=op_dtypes)

‎numpy/_core/tests/test_numeric.py

Copy file name to clipboardExpand all lines: numpy/_core/tests/test_numeric.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4148,7 +4148,7 @@ def test_broadcast_error_kwargs(self):
41484148
assert_equal(mit.numiter, mit2.numiter)
41494149
assert_(mit.iters[0].base is mit2.iters[0].base)
41504150

4151-
assert_raises(ValueError, np.broadcast, 1, **{'x': 1})
4151+
assert_raises(ValueError, np.broadcast, 1, x=1)
41524152

41534153
def test_shape_mismatch_error_message(self):
41544154
with pytest.raises(ValueError, match=r"arg 0 with shape \(1, 3\) and "

‎numpy/_core/tests/test_scalarprint.py

Copy file name to clipboardExpand all lines: numpy/_core/tests/test_scalarprint.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def test_ppc64_ibm_double_double128(self):
316316
# which happens when the first double is normal and the second is
317317
# subnormal.
318318
x = np.float128('2.123123123123123123123123123123123e-286')
319-
got = [str(x/np.float128('2e' + str(i))) for i in range(0,40)]
319+
got = [str(x/np.float128('2e' + str(i))) for i in range(40)]
320320
expected = [
321321
"1.06156156156156156156156156156157e-286",
322322
"1.06156156156156156156156156156158e-287",

‎numpy/_core/tests/test_simd.py

Copy file name to clipboardExpand all lines: numpy/_core/tests/test_simd.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ def test_lut(self, intrin, table_size, elsize):
891891
return
892892
intrin = eval(intrin)
893893
idx_itrin = getattr(self.npyv, f"setall_u{elsize}")
894-
table = range(0, table_size)
894+
table = range(table_size)
895895
for i in table:
896896
broadi = self.setall(i)
897897
idx = idx_itrin(i)

‎numpy/_core/tests/test_simd_module.py

Copy file name to clipboardExpand all lines: numpy/_core/tests/test_simd_module.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def test_truncate_f32(self):
9393
assert round(f32, 1) == 0.1
9494

9595
def test_compare(self):
96-
data_range = range(0, npyv.nlanes_u32)
96+
data_range = range(npyv.nlanes_u32)
9797
vdata = npyv.load_u32(data_range)
9898
assert vdata == list(data_range)
9999
assert vdata == tuple(data_range)

‎numpy/_core/tests/test_ufunc.py

Copy file name to clipboardExpand all lines: numpy/_core/tests/test_ufunc.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3002,7 +3002,7 @@ def test_addition_reduce_negative_zero(dtype, use_initial):
30023002

30033003
# Test various length, in case SIMD paths or chunking play a role.
30043004
# 150 extends beyond the pairwise blocksize; probably not important.
3005-
for i in range(0, 150):
3005+
for i in range(150):
30063006
arr = np.array([neg_zero] * i, dtype=dtype)
30073007
res = np.sum(arr, **kwargs)
30083008
if i > 0 or use_initial:

‎numpy/distutils/fcompiler/gnu.py

Copy file name to clipboardExpand all lines: numpy/distutils/fcompiler/gnu.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def gnu_version_match(self, version_string):
6161
r'GNU Fortran.*?\-?([0-9-.]+\.[0-9-.]+)', version_string)
6262
if m:
6363
v = m.group(1)
64-
if v.startswith('0') or v.startswith('2') or v.startswith('3'):
64+
if v.startswith(('0', '2', '3')):
6565
# the '0' is for early g77's
6666
return ('g77', v)
6767
else:

‎numpy/distutils/system_info.py

Copy file name to clipboardExpand all lines: numpy/distutils/system_info.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def _parse_env_order(base_order, env):
447447
if order_str is None:
448448
return base_order, []
449449

450-
neg = order_str.startswith('^') or order_str.startswith('!')
450+
neg = order_str.startswith(('^', '!'))
451451
# Check format
452452
order_str_l = list(order_str)
453453
sum_neg = order_str_l.count('^') + order_str_l.count('!')

‎numpy/distutils/tests/test_system_info.py

Copy file name to clipboardExpand all lines: numpy/distutils/tests/test_system_info.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ def setup_method(self):
152152
self._lib2 = os.path.join(self._dir2, 'libbar.so')
153153
# Update local site.cfg
154154
global simple_site, site_cfg
155-
site_cfg = simple_site.format(**{
156-
'dir1': self._dir1,
157-
'lib1': self._lib1,
158-
'dir2': self._dir2,
159-
'lib2': self._lib2,
160-
'pathsep': os.pathsep,
161-
'lib2_escaped': _shell_utils.NativeParser.join([self._lib2])
162-
})
155+
site_cfg = simple_site.format(
156+
dir1=self._dir1,
157+
lib1=self._lib1,
158+
dir2=self._dir2,
159+
lib2=self._lib2,
160+
pathsep=os.pathsep,
161+
lib2_escaped=_shell_utils.NativeParser.join([self._lib2])
162+
)
163163
# Write site.cfg
164164
fd, self._sitecfg = mkstemp()
165165
os.close(fd)

‎numpy/lib/_polynomial_impl.py

Copy file name to clipboardExpand all lines: numpy/lib/_polynomial_impl.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ def polydiv(u, v):
10391039
scale = 1. / v[0]
10401040
q = NX.zeros((max(m - n + 1, 1),), w.dtype)
10411041
r = u.astype(w.dtype)
1042-
for k in range(0, m-n+1):
1042+
for k in range(m-n+1):
10431043
d = scale * r[k]
10441044
q[k] = d
10451045
r[k:k+n+1] -= d*v

‎numpy/lib/tests/test_nanfunctions.py

Copy file name to clipboardExpand all lines: numpy/lib/tests/test_nanfunctions.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ def test_float_special(self):
10211021
assert_equal(np.nanmedian(a), -2.5)
10221022
assert_equal(np.nanmedian(a, axis=-1), [-1., -2.5, inf])
10231023

1024-
for i in range(0, 10):
1024+
for i in range(10):
10251025
for j in range(1, 10):
10261026
a = np.array([([np.nan] * i) + ([inf] * j)] * 2)
10271027
assert_equal(np.nanmedian(a), inf)

‎numpy/linalg/_linalg.py

Copy file name to clipboardExpand all lines: numpy/linalg/_linalg.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def tensorsolve(a, b, axes=None):
289289
an = a.ndim
290290

291291
if axes is not None:
292-
allaxes = list(range(0, an))
292+
allaxes = list(range(an))
293293
for k in axes:
294294
allaxes.remove(k)
295295
allaxes.insert(an, k)

‎numpy/ma/tests/test_extras.py

Copy file name to clipboardExpand all lines: numpy/ma/tests/test_extras.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ def test_special(self):
12371237
assert_equal(np.ma.median(a), -2.5)
12381238
assert_equal(np.ma.median(a, axis=1), [-1., -2.5, inf])
12391239

1240-
for i in range(0, 10):
1240+
for i in range(10):
12411241
for j in range(1, 10):
12421242
a = np.array([([np.nan] * i) + ([inf] * j)] * 2)
12431243
a = np.ma.masked_array(a, mask=np.isnan(a))

‎numpy/polynomial/tests/test_chebyshev.py

Copy file name to clipboardExpand all lines: numpy/polynomial/tests/test_chebyshev.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,8 @@ def powx(x, p):
501501
return x**p
502502

503503
x = np.linspace(-1, 1, 10)
504-
for deg in range(0, 10):
505-
for p in range(0, deg + 1):
504+
for deg in range(10):
505+
for p in range(deg + 1):
506506
c = cheb.chebinterpolate(powx, deg, (p,))
507507
assert_almost_equal(cheb.chebval(x, c), powx(x, p), decimal=12)
508508

‎numpy/polynomial/tests/test_classes.py

Copy file name to clipboardExpand all lines: numpy/polynomial/tests/test_classes.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ def powx(x, p):
601601
return x**p
602602

603603
x = np.linspace(0, 2, 10)
604-
for deg in range(0, 10):
605-
for t in range(0, deg + 1):
604+
for deg in range(10):
605+
for t in range(deg + 1):
606606
p = Chebyshev.interpolate(powx, deg, domain=[0, 2], args=(t,))
607607
assert_almost_equal(p(x), powx(x, t), decimal=11)

‎numpy/testing/_private/extbuild.py

Copy file name to clipboardExpand all lines: numpy/testing/_private/extbuild.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ def _c_compile(cfile, outputfilename, include_dirs, libraries,
194194
"-O0", "-g", "-Werror=implicit-function-declaration", "-fPIC"]
195195
else:
196196
compile_extra = []
197-
pass
198197

199198
return build(
200199
cfile, outputfilename,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.