Skip to content

Commit 6a3f10f

Browse files
authored
Merge pull request numpy#27307 from DimitriPapadopoulos/W
MAINT: Apply ruff/pycodestyle warning rules (W)
2 parents dc5419f + 177bd62 commit 6a3f10f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+211
-211
lines changed

benchmarks/benchmarks/bench_linalg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def time_norm_small_array(self):
111111

112112
def time_det_small_array(self):
113113
np.linalg.det(self.array_5_5)
114-
114+
115115
class Lstsq(Benchmark):
116116
def setup(self):
117117
self.a = get_squares_()['float64']

benchmarks/benchmarks/bench_polynomial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def time_polynomial_evaluation_array_3(self):
2222

2323
def time_polynomial_evaluation_array_1000(self):
2424
self.polynomial_degree2(self.array1000)
25-
25+
2626
def time_polynomial_addition(self):
2727
_ = self.polynomial_degree2 + self.polynomial_degree2
28-
28+
2929

benchmarks/benchmarks/bench_ufunc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ def setup(self, dtype):
597597
N = 1000000
598598
self.a = np.random.randint(20, size=N).astype(dtype)
599599
self.b = np.random.randint(4, size=N).astype(dtype)
600-
600+
601601
def time_pow(self, dtype):
602602
np.power(self.a, self.b)
603603

doc/source/user/plots/matplotlib1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
a = np.array([2, 1, 5, 7, 4, 6, 8, 14, 10, 9, 18, 20, 22])
55

6-
plt.plot(a)
7-
plt.show()
6+
plt.plot(a)
7+
plt.show()

doc/source/user/plots/matplotlib2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
y = np.linspace(0, 10, 20)
66
plt.plot(x, y, 'purple') # line
77
plt.plot(x, y, 'o') # dots
8-
plt.show()
8+
plt.show()

doc/source/user/plots/matplotlib3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111

1212
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='viridis')
1313

14-
plt.show()
14+
plt.show()

numpy/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
vstack, where, zeros, zeros_like
170170
)
171171

172-
# NOTE: It's still under discussion whether these aliases
172+
# NOTE: It's still under discussion whether these aliases
173173
# should be removed.
174174
for ta in ["float96", "float128", "complex192", "complex256"]:
175175
try:
@@ -184,21 +184,21 @@
184184
histogram, histogram_bin_edges, histogramdd
185185
)
186186
from .lib._nanfunctions_impl import (
187-
nanargmax, nanargmin, nancumprod, nancumsum, nanmax, nanmean,
187+
nanargmax, nanargmin, nancumprod, nancumsum, nanmax, nanmean,
188188
nanmedian, nanmin, nanpercentile, nanprod, nanquantile, nanstd,
189189
nansum, nanvar
190190
)
191191
from .lib._function_base_impl import (
192-
select, piecewise, trim_zeros, copy, iterable, percentile, diff,
192+
select, piecewise, trim_zeros, copy, iterable, percentile, diff,
193193
gradient, angle, unwrap, sort_complex, flip, rot90, extract, place,
194194
vectorize, asarray_chkfinite, average, bincount, digitize, cov,
195195
corrcoef, median, sinc, hamming, hanning, bartlett, blackman,
196196
kaiser, trapezoid, trapz, i0, meshgrid, delete, insert, append,
197197
interp, quantile
198198
)
199199
from .lib._twodim_base_impl import (
200-
diag, diagflat, eye, fliplr, flipud, tri, triu, tril, vander,
201-
histogram2d, mask_indices, tril_indices, tril_indices_from,
200+
diag, diagflat, eye, fliplr, flipud, tri, triu, tril, vander,
201+
histogram2d, mask_indices, tril_indices, tril_indices_from,
202202
triu_indices, triu_indices_from
203203
)
204204
from .lib._shape_base_impl import (
@@ -207,7 +207,7 @@
207207
take_along_axis, tile, vsplit
208208
)
209209
from .lib._type_check_impl import (
210-
iscomplexobj, isrealobj, imag, iscomplex, isreal, nan_to_num, real,
210+
iscomplexobj, isrealobj, imag, iscomplex, isreal, nan_to_num, real,
211211
real_if_close, typename, mintypecode, common_type
212212
)
213213
from .lib._arraysetops_impl import (
@@ -232,7 +232,7 @@
232232
)
233233
from .lib._index_tricks_impl import (
234234
diag_indices_from, diag_indices, fill_diagonal, ndindex, ndenumerate,
235-
ix_, c_, r_, s_, ogrid, mgrid, unravel_index, ravel_multi_index,
235+
ix_, c_, r_, s_, ogrid, mgrid, unravel_index, ravel_multi_index,
236236
index_exp
237237
)
238238

@@ -246,7 +246,7 @@
246246
# (experimental label) are not added here, because `from numpy import *`
247247
# must not raise any warnings - that's too disruptive.
248248
__numpy_submodules__ = {
249-
"linalg", "fft", "dtypes", "random", "polynomial", "ma",
249+
"linalg", "fft", "dtypes", "random", "polynomial", "ma",
250250
"exceptions", "lib", "ctypeslib", "testing", "typing",
251251
"f2py", "test", "rec", "char", "core", "strings",
252252
}
@@ -395,7 +395,7 @@ def __getattr__(attr):
395395

396396
if attr in __former_attrs__:
397397
raise AttributeError(__former_attrs__[attr], name=None)
398-
398+
399399
if attr in __expired_attributes__:
400400
raise AttributeError(
401401
f"`np.{attr}` was removed in the NumPy 2.0 release. "
@@ -419,7 +419,7 @@ def __dir__():
419419
globals().keys() | __numpy_submodules__
420420
)
421421
public_symbols -= {
422-
"matrixlib", "matlib", "tests", "conftest", "version",
422+
"matrixlib", "matlib", "tests", "conftest", "version",
423423
"compat", "distutils", "array_api"
424424
}
425425
return list(public_symbols)
@@ -495,7 +495,7 @@ def _mac_os_check():
495495
def hugepage_setup():
496496
"""
497497
We usually use madvise hugepages support, but on some old kernels it
498-
is slow and thus better avoided. Specifically kernel version 4.6
498+
is slow and thus better avoided. Specifically kernel version 4.6
499499
had a bug fix which probably fixed this:
500500
https://github.com/torvalds/linux/commit/7cf91a98e607c2f935dbcc177d70011e95b8faff
501501
"""
@@ -504,7 +504,7 @@ def hugepage_setup():
504504
# If there is an issue with parsing the kernel version,
505505
# set use_hugepage to 0. Usage of LooseVersion will handle
506506
# the kernel version parsing better, but avoided since it
507-
# will increase the import time.
507+
# will increase the import time.
508508
# See: #16679 for related discussion.
509509
try:
510510
use_hugepage = 1

numpy/_core/_add_newdocs_scalars.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,12 @@ def add_newdoc_for_scalar_type(obj, fixed_aliases, doc):
292292
``1970-01-01T00:00:00``.
293293
If created from string, the string can be in ISO 8601 date
294294
or datetime format.
295-
295+
296296
When parsing a string to create a datetime object, if the string contains
297-
a trailing timezone (A 'Z' or a timezone offset), the timezone will be
297+
a trailing timezone (A 'Z' or a timezone offset), the timezone will be
298298
dropped and a User Warning is given.
299-
300-
Datetime64 objects should be considered to be UTC and therefore have an
299+
300+
Datetime64 objects should be considered to be UTC and therefore have an
301301
offset of +0000.
302302
303303
>>> np.datetime64(10, 'Y')

numpy/_core/_type_aliases.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
# extra aliases are added only to `sctypeDict`
6565
# to support dtype name access, such as`np.dtype("float")`
66-
_extra_aliases = {
66+
_extra_aliases = {
6767
"float": "float64",
6868
"complex": "complex128",
6969
"object": "object_",
@@ -104,8 +104,8 @@
104104

105105
# find proper group for each concrete type
106106
for type_group, abstract_type in [
107-
("int", ma.signedinteger), ("uint", ma.unsignedinteger),
108-
("float", ma.floating), ("complex", ma.complexfloating),
107+
("int", ma.signedinteger), ("uint", ma.unsignedinteger),
108+
("float", ma.floating), ("complex", ma.complexfloating),
109109
("others", ma.generic)
110110
]:
111111
if issubclass(concrete_type, abstract_type):

numpy/_core/code_generators/ufunc_docstrings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3707,7 +3707,7 @@ def add_newdoc(place, name, doc):
37073707
There is more than one definition of sign in common use for complex
37083708
numbers. The definition used here, :math:`x/|x|`, is the more common
37093709
and useful one, but is different from the one used in numpy prior to
3710-
version 2.0, :math:`x/\\sqrt{x*x}`, which is equivalent to
3710+
version 2.0, :math:`x/\\sqrt{x*x}`, which is equivalent to
37113711
``sign(x.real) + 0j if x.real != 0 else sign(x.imag) + 0j``.
37123712
37133713
Examples
@@ -4650,7 +4650,7 @@ def add_newdoc(place, name, doc):
46504650
array(True)
46514651
>>> a = np.array(["hello", "HELLO", "Hello"])
46524652
>>> np.strings.isupper(a)
4653-
array([False, True, False])
4653+
array([False, True, False])
46544654
46554655
""")
46564656

0 commit comments

Comments
 (0)