Skip to content

Commit ba5bf8d

Browse files
DimitriPapadopoulosMaanasArora
authored andcommitted
STY: Partially apply ruff/pycodestyle rule E265
Block comment should start with `# ` For now, keep commented out code as is.
1 parent ddadd18 commit ba5bf8d

34 files changed

+147
-147
lines changed

numpy/_core/code_generators/generate_umath.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,16 @@ def english_upper(s):
259259
return uppered
260260

261261

262-
#each entry in defdict is a Ufunc object.
262+
# each entry in defdict is a Ufunc object.
263263

264-
#name: [string of chars for which it is defined,
265-
# string of characters using func interface,
266-
# tuple of strings giving funcs for data,
267-
# (in, out), or (instr, outstr) giving the signature as character codes,
268-
# identity,
269-
# docstring,
270-
# output specification (optional)
271-
# ]
264+
# name: [string of chars for which it is defined,
265+
# string of characters using func interface,
266+
# tuple of strings giving funcs for data,
267+
# (in, out), or (instr, outstr) giving the signature as character codes,
268+
# identity,
269+
# docstring,
270+
# output specification (optional)
271+
# ]
272272

273273
chartoname = {
274274
'?': 'bool',
@@ -396,7 +396,7 @@ def english_upper(s):
396396
TD(O, f='PyNumber_Multiply'),
397397
indexed=intfltcmplx
398398
),
399-
#'true_divide' : aliased to divide in umathmodule.c:initumath
399+
# 'true_divide' : aliased to divide in umathmodule.c:initumath
400400
'floor_divide':
401401
Ufunc(2, 1, None, # One is only a unit to the right, not the left
402402
docstrings.get('numpy._core.umath.floor_divide'),
@@ -1382,7 +1382,7 @@ def indent(st, spaces):
13821382
}
13831383
}
13841384

1385-
#for each name
1385+
# for each name
13861386
# 1) create functions, data, and signature
13871387
# 2) fill in functions and data in InitOperators
13881388
# 3) add function.

numpy/_core/records.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def __getattribute__(self, attr):
228228
try:
229229
dt = obj.dtype
230230
except AttributeError:
231-
#happens if field is Object type
231+
# happens if field is Object type
232232
return obj
233233
if dt.names is not None:
234234
return obj.view((self.__class__, obj.dtype))

numpy/_core/tests/test_dtype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ def test_shape_invalid(self):
742742
assert_raises(ValueError, np.dtype, [('a', 'f4', (-1, -1))])
743743

744744
def test_alignment(self):
745-
#Check that subarrays are aligned
745+
# Check that subarrays are aligned
746746
t1 = np.dtype('(1,)i4', align=True)
747747
t2 = np.dtype('2i4', align=True)
748748
assert_equal(t1.alignment, t2.alignment)

numpy/_core/tests/test_einsum.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ def test_path_type_input(self):
12401240
assert_almost_equal(noopt, opt)
12411241

12421242
def test_path_type_input_internal_trace(self):
1243-
#gh-20962
1243+
# gh-20962
12441244
path_test = self.build_operands('cab,cdd->ab')
12451245
exp_path = ['einsum_path', (1,), (0, 1)]
12461246

@@ -1266,7 +1266,7 @@ def test_path_type_input_invalid(self):
12661266
RuntimeError, np.einsum_path, *path_test, optimize=exp_path)
12671267

12681268
def test_spaces(self):
1269-
#gh-10794
1269+
# gh-10794
12701270
arr = np.array([[1]])
12711271
for sp in itertools.product(['', ' '], repeat=4):
12721272
# no error for any spacing
@@ -1279,7 +1279,7 @@ def test_overlap():
12791279
# sanity check
12801280
c = np.einsum('ij,jk->ik', a, b)
12811281
assert_equal(c, d)
1282-
#gh-10080, out overlaps one of the operands
1282+
# gh-10080, out overlaps one of the operands
12831283
c = np.einsum('ij,jk->ik', a, b, out=b)
12841284
assert_equal(c, d)
12851285

numpy/_core/tests/test_indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def test_unaligned(self):
492492
x = x.view(np.dtype("S8"))
493493
x[...] = np.array("b" * 8, dtype="S")
494494
b = np.arange(d.size)
495-
#trivial
495+
# trivial
496496
assert_equal(d[b], d)
497497
d[b] = x
498498
# nontrivial

numpy/_core/tests/test_multiarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,11 +2295,11 @@ def test_void_sort(self):
22952295
arr[::-1].sort()
22962296

22972297
def test_sort_raises(self):
2298-
#gh-9404
2298+
# gh-9404
22992299
arr = np.array([0, datetime.now(), 1], dtype=object)
23002300
for kind in self.sort_kinds:
23012301
assert_raises(TypeError, arr.sort, kind=kind)
2302-
#gh-3879
2302+
# gh-3879
23032303

23042304
class Raiser:
23052305
def raises_anything(*args, **kwargs):

numpy/_core/tests/test_nditer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ def test_iter_object_arrays_conversions():
11131113
x[...] += 1
11141114
assert_equal(a, np.arange(6) + 1)
11151115

1116-
#Non-contiguous value array
1116+
# Non-contiguous value array
11171117
a = np.zeros((6,), dtype=[('p', 'i1'), ('a', 'i4')])
11181118
a = a['a']
11191119
a[:] = np.arange(6) + 98172488

numpy/_core/tests/test_numeric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4142,7 +4142,7 @@ def test_number_of_arguments(self):
41424142
assert_equal(mit.numiter, j)
41434143

41444144
def test_broadcast_error_kwargs(self):
4145-
#gh-13455
4145+
# gh-13455
41464146
arrs = [np.empty((5, 6, 7))]
41474147
mit = np.broadcast(*arrs)
41484148
mit2 = np.broadcast(*arrs, **{}) # noqa: PIE804

numpy/_core/tests/test_records.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,31 +185,31 @@ def test_recarray_views(self):
185185
dtype=[('foo', int), ('bar', 'S4')])
186186
b = np.array([1, 2, 3, 4, 5], dtype=np.int64)
187187

188-
#check that np.rec.array gives right dtypes
188+
# check that np.rec.array gives right dtypes
189189
assert_equal(np.rec.array(a).dtype.type, np.record)
190190
assert_equal(type(np.rec.array(a)), np.recarray)
191191
assert_equal(np.rec.array(b).dtype.type, np.int64)
192192
assert_equal(type(np.rec.array(b)), np.recarray)
193193

194-
#check that viewing as recarray does the same
194+
# check that viewing as recarray does the same
195195
assert_equal(a.view(np.recarray).dtype.type, np.record)
196196
assert_equal(type(a.view(np.recarray)), np.recarray)
197197
assert_equal(b.view(np.recarray).dtype.type, np.int64)
198198
assert_equal(type(b.view(np.recarray)), np.recarray)
199199

200-
#check that view to non-structured dtype preserves type=np.recarray
200+
# check that view to non-structured dtype preserves type=np.recarray
201201
r = np.rec.array(np.ones(4, dtype="f4,i4"))
202202
rv = r.view('f8').view('f4,i4')
203203
assert_equal(type(rv), np.recarray)
204204
assert_equal(rv.dtype.type, np.record)
205205

206-
#check that getitem also preserves np.recarray and np.record
206+
# check that getitem also preserves np.recarray and np.record
207207
r = np.rec.array(np.ones(4, dtype=[('a', 'i4'), ('b', 'i4'),
208208
('c', 'i4,i4')]))
209209
assert_equal(r['c'].dtype.type, np.record)
210210
assert_equal(type(r['c']), np.recarray)
211211

212-
#and that it preserves subclasses (gh-6949)
212+
# and that it preserves subclasses (gh-6949)
213213
class C(np.recarray):
214214
pass
215215

@@ -233,7 +233,7 @@ class C(np.recarray):
233233
assert_equal(r.view('V8').dtype.type, np.void)
234234
assert_equal(r.view(('i8', 'i4,i4')).dtype.type, np.int64)
235235

236-
#check that we can undo the view
236+
# check that we can undo the view
237237
arrs = [np.ones(4, dtype='f4,i4'), np.ones(4, dtype='f8')]
238238
for arr in arrs:
239239
rec = np.rec.array(arr)

numpy/_core/tests/test_regression.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,18 +1243,18 @@ def test_void_scalar_with_titles(self):
12431243
assert_(arr[0][1] == 4)
12441244

12451245
def test_void_scalar_constructor(self):
1246-
#Issue #1550
1246+
# Issue #1550
12471247

1248-
#Create test string data, construct void scalar from data and assert
1249-
#that void scalar contains original data.
1248+
# Create test string data, construct void scalar from data and assert
1249+
# that void scalar contains original data.
12501250
test_string = np.array("test")
12511251
test_string_void_scalar = np._core.multiarray.scalar(
12521252
np.dtype(("V", test_string.dtype.itemsize)), test_string.tobytes())
12531253

12541254
assert_(test_string_void_scalar.view(test_string.dtype) == test_string)
12551255

1256-
#Create record scalar, construct from data and assert that
1257-
#reconstructed scalar is correct.
1256+
# Create record scalar, construct from data and assert that
1257+
# reconstructed scalar is correct.
12581258
test_record = np.ones((), "i,i")
12591259
test_record_void_scalar = np._core.multiarray.scalar(
12601260
test_record.dtype, test_record.tobytes())
@@ -2456,7 +2456,7 @@ def __len__(self):
24562456

24572457
@pytest.mark.skipif(sys.maxsize < 2 ** 31 + 1, reason='overflows 32-bit python')
24582458
def test_to_ctypes(self):
2459-
#gh-14214
2459+
# gh-14214
24602460
arr = np.zeros((2 ** 31 + 1,), 'b')
24612461
assert arr.size * arr.itemsize > 2 ** 31
24622462
c_arr = np.ctypeslib.as_ctypes(arr)

0 commit comments

Comments
 (0)