Skip to content

Commit 87000d6

Browse files
MAINT: Apply ruff/Pycodestyle rule E231
E231 Missing whitespace after ',' Apply to a single file to please the current linter.
1 parent 862d800 commit 87000d6

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

numpy/_core/tests/test_nditer.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def test_iter_best_order_multi_index_3d():
271271
assert_equal(iter_multi_index(i),
272272
[(0, 2, 0), (0, 2, 1), (0, 1, 0), (0, 1, 1), (0, 0, 0), (0, 0, 1),
273273
(1, 2, 0), (1, 2, 1), (1, 1, 0), (1, 1, 1), (1, 0, 0), (1, 0, 1)])
274-
i = nditer(a.reshape(2, 3, 2)[:,:, ::-1], ['multi_index'], [['readonly']])
274+
i = nditer(a.reshape(2, 3, 2)[:, :, ::-1], ['multi_index'], [['readonly']])
275275
assert_equal(iter_multi_index(i),
276276
[(0, 0, 1), (0, 0, 0), (0, 1, 1), (0, 1, 0), (0, 2, 1), (0, 2, 0),
277277
(1, 0, 1), (1, 0, 0), (1, 1, 1), (1, 1, 0), (1, 2, 1), (1, 2, 0)])
@@ -286,7 +286,7 @@ def test_iter_best_order_multi_index_3d():
286286
assert_equal(iter_multi_index(i),
287287
[(0, 2, 0), (1, 2, 0), (0, 1, 0), (1, 1, 0), (0, 0, 0), (1, 0, 0),
288288
(0, 2, 1), (1, 2, 1), (0, 1, 1), (1, 1, 1), (0, 0, 1), (1, 0, 1)])
289-
i = nditer(a.reshape(2, 3, 2).copy(order='F')[:,:, ::-1],
289+
i = nditer(a.reshape(2, 3, 2).copy(order='F')[:, :, ::-1],
290290
['multi_index'], [['readonly']])
291291
assert_equal(iter_multi_index(i),
292292
[(0, 0, 1), (1, 0, 1), (0, 1, 1), (1, 1, 1), (0, 2, 1), (1, 2, 1),
@@ -352,7 +352,7 @@ def test_iter_best_order_c_index_3d():
352352
i = nditer(a.reshape(2, 3, 2)[:, ::-1], ['c_index'], [['readonly']])
353353
assert_equal(iter_indices(i),
354354
[4, 5, 2, 3, 0, 1, 10, 11, 8, 9, 6, 7])
355-
i = nditer(a.reshape(2, 3, 2)[:,:, ::-1], ['c_index'], [['readonly']])
355+
i = nditer(a.reshape(2, 3, 2)[:, :, ::-1], ['c_index'], [['readonly']])
356356
assert_equal(iter_indices(i),
357357
[1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10])
358358
# 3D reversed Fortran-order
@@ -364,7 +364,7 @@ def test_iter_best_order_c_index_3d():
364364
['c_index'], [['readonly']])
365365
assert_equal(iter_indices(i),
366366
[4, 10, 2, 8, 0, 6, 5, 11, 3, 9, 1, 7])
367-
i = nditer(a.reshape(2, 3, 2).copy(order='F')[:,:, ::-1],
367+
i = nditer(a.reshape(2, 3, 2).copy(order='F')[:, :, ::-1],
368368
['c_index'], [['readonly']])
369369
assert_equal(iter_indices(i),
370370
[1, 7, 3, 9, 5, 11, 0, 6, 2, 8, 4, 10])
@@ -429,7 +429,7 @@ def test_iter_best_order_f_index_3d():
429429
i = nditer(a.reshape(2, 3, 2)[:, ::-1], ['f_index'], [['readonly']])
430430
assert_equal(iter_indices(i),
431431
[4, 10, 2, 8, 0, 6, 5, 11, 3, 9, 1, 7])
432-
i = nditer(a.reshape(2, 3, 2)[:,:, ::-1], ['f_index'], [['readonly']])
432+
i = nditer(a.reshape(2, 3, 2)[:, :, ::-1], ['f_index'], [['readonly']])
433433
assert_equal(iter_indices(i),
434434
[6, 0, 8, 2, 10, 4, 7, 1, 9, 3, 11, 5])
435435
# 3D reversed Fortran-order
@@ -441,7 +441,7 @@ def test_iter_best_order_f_index_3d():
441441
['f_index'], [['readonly']])
442442
assert_equal(iter_indices(i),
443443
[4, 5, 2, 3, 0, 1, 10, 11, 8, 9, 6, 7])
444-
i = nditer(a.reshape(2, 3, 2).copy(order='F')[:,:, ::-1],
444+
i = nditer(a.reshape(2, 3, 2).copy(order='F')[:, :, ::-1],
445445
['f_index'], [['readonly']])
446446
assert_equal(iter_indices(i),
447447
[6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5])
@@ -481,15 +481,15 @@ def test_iter_no_inner_dim_coalescing():
481481

482482
# Skipping the last element in a dimension prevents coalescing
483483
# with the next-bigger dimension
484-
a = arange(24).reshape(2, 3, 4)[:,:, :-1]
484+
a = arange(24).reshape(2, 3, 4)[:, :, :-1]
485485
i = nditer(a, ['external_loop'], [['readonly']])
486486
assert_equal(i.ndim, 2)
487487
assert_equal(i[0].shape, (3,))
488-
a = arange(24).reshape(2, 3, 4)[:, :-1,:]
488+
a = arange(24).reshape(2, 3, 4)[:, :-1, :]
489489
i = nditer(a, ['external_loop'], [['readonly']])
490490
assert_equal(i.ndim, 2)
491491
assert_equal(i[0].shape, (8,))
492-
a = arange(24).reshape(2, 3, 4)[:-1,:,:]
492+
a = arange(24).reshape(2, 3, 4)[:-1, :, :]
493493
i = nditer(a, ['external_loop'], [['readonly']])
494494
assert_equal(i.ndim, 1)
495495
assert_equal(i[0].shape, (12,))
@@ -761,9 +761,9 @@ def test_iter_flags_errors():
761761
a.flags.writeable = True
762762
# Multi-indices available only with the multi_index flag
763763
i = nditer(arange(6), [], [['readonly']])
764-
assert_raises(ValueError, lambda i:i.multi_index, i)
764+
assert_raises(ValueError, lambda i: i.multi_index, i)
765765
# Index available only with an index flag
766-
assert_raises(ValueError, lambda i:i.index, i)
766+
assert_raises(ValueError, lambda i: i.index, i)
767767
# GotoCoords and GotoIndex incompatible with buffering or no_inner
768768

769769
def assign_multi_index(i):
@@ -911,7 +911,7 @@ def test_iter_array_cast():
911911
# The memory layout of the temporary should match a (a is (48,4,16))
912912
# except negative strides get flipped to positive strides.
913913
assert_equal(i.operands[0].strides, (96, 8, 32))
914-
a = a[::-1,:, ::-1]
914+
a = a[::-1, :, ::-1]
915915
i = nditer(a, [], [['readonly', 'copy']],
916916
casting='safe',
917917
op_dtypes=[np.dtype('f8')])
@@ -1049,7 +1049,7 @@ def test_iter_scalar_cast_errors():
10491049
def test_iter_object_arrays_basic():
10501050
# Check that object arrays work
10511051

1052-
obj = {'a':3,'b':'d'}
1052+
obj = {'a': 3, 'b': 'd'}
10531053
a = np.array([[1, 2, 3], None, obj, None], dtype='O')
10541054
if HAS_REFCOUNT:
10551055
rc = sys.getrefcount(obj)
@@ -1677,12 +1677,12 @@ def test_iter_remove_axis():
16771677

16781678
i = nditer(a, ['multi_index'])
16791679
i.remove_axis(1)
1680-
assert_equal(list(i), a[:, 0,:].ravel())
1680+
assert_equal(list(i), a[:, 0, :].ravel())
16811681

1682-
a = a[::-1,:,:]
1682+
a = a[::-1, :, :]
16831683
i = nditer(a, ['multi_index'])
16841684
i.remove_axis(0)
1685-
assert_equal(list(i), a[0,:,:].ravel())
1685+
assert_equal(list(i), a[0, :, :].ravel())
16861686

16871687
def test_iter_remove_multi_index_inner_loop():
16881688
# Check that removing multi-index support works
@@ -1701,7 +1701,7 @@ def test_iter_remove_multi_index_inner_loop():
17011701

17021702
assert_equal(before, after)
17031703
assert_equal(i.ndim, 1)
1704-
assert_raises(ValueError, lambda i:i.shape, i)
1704+
assert_raises(ValueError, lambda i: i.shape, i)
17051705
assert_equal(i.itviews[0].shape, (24,))
17061706

17071707
# Removing the inner loop means there's just one iteration
@@ -1847,9 +1847,9 @@ def test_iter_buffering_delayed_alloc():
18471847
casting='unsafe',
18481848
op_dtypes='f4')
18491849
assert_(i.has_delayed_bufalloc)
1850-
assert_raises(ValueError, lambda i:i.multi_index, i)
1851-
assert_raises(ValueError, lambda i:i[0], i)
1852-
assert_raises(ValueError, lambda i:i[0:2], i)
1850+
assert_raises(ValueError, lambda i: i.multi_index, i)
1851+
assert_raises(ValueError, lambda i: i[0], i)
1852+
assert_raises(ValueError, lambda i: i[0:2], i)
18531853

18541854
def assign_iter(i):
18551855
i[0] = 0
@@ -2240,7 +2240,7 @@ def test_iter_buffered_cast_subarray():
22402240
for x in i:
22412241
assert_equal(x['a'][:2, 0], a[count]['a'][:, 0])
22422242
assert_equal(x['a'][:2, 1], a[count]['a'][:, 0])
2243-
assert_equal(x['a'][2,:], [0, 0])
2243+
assert_equal(x['a'][2, :], [0, 0])
22442244
count += 1
22452245

22462246
# matrix -> matrix (truncates and zero-pads)
@@ -2256,7 +2256,7 @@ def test_iter_buffered_cast_subarray():
22562256
for x in i:
22572257
assert_equal(x['a'][:2, 0], a[count]['a'][:, 0])
22582258
assert_equal(x['a'][:2, 1], a[count]['a'][:, 1])
2259-
assert_equal(x['a'][2,:], [0, 0])
2259+
assert_equal(x['a'][2, :], [0, 0])
22602260
count += 1
22612261

22622262
def test_iter_buffering_badwriteback():
@@ -2689,11 +2689,11 @@ def test_iter_buffering_reduction():
26892689
assert_equal(it[0], [1, 2, 1, 2])
26902690

26912691
# Iterator inner loop should take argument contiguity into account
2692-
x = np.ones((7, 13, 8), np.int8)[4:6,1:11:6,1:5].transpose(1, 2, 0)
2692+
x = np.ones((7, 13, 8), np.int8)[4:6, 1:11:6, 1:5].transpose(1, 2, 0)
26932693
x[...] = np.arange(x.size).reshape(x.shape)
26942694
y_base = np.arange(4*4, dtype=np.int8).reshape(4, 4)
26952695
y_base_copy = y_base.copy()
2696-
y = y_base[::2,:,None]
2696+
y = y_base[::2, :, None]
26972697

26982698
it = np.nditer([y, x],
26992699
['buffered', 'external_loop', 'reduce_ok'],
@@ -3174,7 +3174,7 @@ def test_close_equivalent():
31743174
def add_close(x, y, out=None):
31753175
addop = np.add
31763176
it = np.nditer([x, y, out], [],
3177-
[['readonly'], ['readonly'], ['writeonly','allocate']])
3177+
[['readonly'], ['readonly'], ['writeonly', 'allocate']])
31783178
for (a, b, c) in it:
31793179
addop(a, b, out=c)
31803180
ret = it.operands[2]
@@ -3184,7 +3184,7 @@ def add_close(x, y, out=None):
31843184
def add_context(x, y, out=None):
31853185
addop = np.add
31863186
it = np.nditer([x, y, out], [],
3187-
[['readonly'], ['readonly'], ['writeonly','allocate']])
3187+
[['readonly'], ['readonly'], ['writeonly', 'allocate']])
31883188
with it:
31893189
for (a, b, c) in it:
31903190
addop(a, b, out=c)

0 commit comments

Comments
 (0)