@@ -271,7 +271,7 @@ def test_iter_best_order_multi_index_3d():
271
271
assert_equal (iter_multi_index (i ),
272
272
[(0 , 2 , 0 ), (0 , 2 , 1 ), (0 , 1 , 0 ), (0 , 1 , 1 ), (0 , 0 , 0 ), (0 , 0 , 1 ),
273
273
(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' ]])
275
275
assert_equal (iter_multi_index (i ),
276
276
[(0 , 0 , 1 ), (0 , 0 , 0 ), (0 , 1 , 1 ), (0 , 1 , 0 ), (0 , 2 , 1 ), (0 , 2 , 0 ),
277
277
(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():
286
286
assert_equal (iter_multi_index (i ),
287
287
[(0 , 2 , 0 ), (1 , 2 , 0 ), (0 , 1 , 0 ), (1 , 1 , 0 ), (0 , 0 , 0 ), (1 , 0 , 0 ),
288
288
(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 ],
290
290
['multi_index' ], [['readonly' ]])
291
291
assert_equal (iter_multi_index (i ),
292
292
[(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():
352
352
i = nditer (a .reshape (2 , 3 , 2 )[:, ::- 1 ], ['c_index' ], [['readonly' ]])
353
353
assert_equal (iter_indices (i ),
354
354
[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' ]])
356
356
assert_equal (iter_indices (i ),
357
357
[1 , 0 , 3 , 2 , 5 , 4 , 7 , 6 , 9 , 8 , 11 , 10 ])
358
358
# 3D reversed Fortran-order
@@ -364,7 +364,7 @@ def test_iter_best_order_c_index_3d():
364
364
['c_index' ], [['readonly' ]])
365
365
assert_equal (iter_indices (i ),
366
366
[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 ],
368
368
['c_index' ], [['readonly' ]])
369
369
assert_equal (iter_indices (i ),
370
370
[1 , 7 , 3 , 9 , 5 , 11 , 0 , 6 , 2 , 8 , 4 , 10 ])
@@ -429,7 +429,7 @@ def test_iter_best_order_f_index_3d():
429
429
i = nditer (a .reshape (2 , 3 , 2 )[:, ::- 1 ], ['f_index' ], [['readonly' ]])
430
430
assert_equal (iter_indices (i ),
431
431
[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' ]])
433
433
assert_equal (iter_indices (i ),
434
434
[6 , 0 , 8 , 2 , 10 , 4 , 7 , 1 , 9 , 3 , 11 , 5 ])
435
435
# 3D reversed Fortran-order
@@ -441,7 +441,7 @@ def test_iter_best_order_f_index_3d():
441
441
['f_index' ], [['readonly' ]])
442
442
assert_equal (iter_indices (i ),
443
443
[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 ],
445
445
['f_index' ], [['readonly' ]])
446
446
assert_equal (iter_indices (i ),
447
447
[6 , 7 , 8 , 9 , 10 , 11 , 0 , 1 , 2 , 3 , 4 , 5 ])
@@ -481,15 +481,15 @@ def test_iter_no_inner_dim_coalescing():
481
481
482
482
# Skipping the last element in a dimension prevents coalescing
483
483
# with the next-bigger dimension
484
- a = arange (24 ).reshape (2 , 3 , 4 )[:,:, :- 1 ]
484
+ a = arange (24 ).reshape (2 , 3 , 4 )[:, :, :- 1 ]
485
485
i = nditer (a , ['external_loop' ], [['readonly' ]])
486
486
assert_equal (i .ndim , 2 )
487
487
assert_equal (i [0 ].shape , (3 ,))
488
- a = arange (24 ).reshape (2 , 3 , 4 )[:, :- 1 ,:]
488
+ a = arange (24 ).reshape (2 , 3 , 4 )[:, :- 1 , :]
489
489
i = nditer (a , ['external_loop' ], [['readonly' ]])
490
490
assert_equal (i .ndim , 2 )
491
491
assert_equal (i [0 ].shape , (8 ,))
492
- a = arange (24 ).reshape (2 , 3 , 4 )[:- 1 ,:, :]
492
+ a = arange (24 ).reshape (2 , 3 , 4 )[:- 1 , :, :]
493
493
i = nditer (a , ['external_loop' ], [['readonly' ]])
494
494
assert_equal (i .ndim , 1 )
495
495
assert_equal (i [0 ].shape , (12 ,))
@@ -761,9 +761,9 @@ def test_iter_flags_errors():
761
761
a .flags .writeable = True
762
762
# Multi-indices available only with the multi_index flag
763
763
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 )
765
765
# 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 )
767
767
# GotoCoords and GotoIndex incompatible with buffering or no_inner
768
768
769
769
def assign_multi_index (i ):
@@ -911,7 +911,7 @@ def test_iter_array_cast():
911
911
# The memory layout of the temporary should match a (a is (48,4,16))
912
912
# except negative strides get flipped to positive strides.
913
913
assert_equal (i .operands [0 ].strides , (96 , 8 , 32 ))
914
- a = a [::- 1 ,:, ::- 1 ]
914
+ a = a [::- 1 , :, ::- 1 ]
915
915
i = nditer (a , [], [['readonly' , 'copy' ]],
916
916
casting = 'safe' ,
917
917
op_dtypes = [np .dtype ('f8' )])
@@ -1049,7 +1049,7 @@ def test_iter_scalar_cast_errors():
1049
1049
def test_iter_object_arrays_basic ():
1050
1050
# Check that object arrays work
1051
1051
1052
- obj = {'a' :3 , 'b' :'d' }
1052
+ obj = {'a' : 3 , 'b' : 'd' }
1053
1053
a = np .array ([[1 , 2 , 3 ], None , obj , None ], dtype = 'O' )
1054
1054
if HAS_REFCOUNT :
1055
1055
rc = sys .getrefcount (obj )
@@ -1677,12 +1677,12 @@ def test_iter_remove_axis():
1677
1677
1678
1678
i = nditer (a , ['multi_index' ])
1679
1679
i .remove_axis (1 )
1680
- assert_equal (list (i ), a [:, 0 ,:].ravel ())
1680
+ assert_equal (list (i ), a [:, 0 , :].ravel ())
1681
1681
1682
- a = a [::- 1 ,:, :]
1682
+ a = a [::- 1 , :, :]
1683
1683
i = nditer (a , ['multi_index' ])
1684
1684
i .remove_axis (0 )
1685
- assert_equal (list (i ), a [0 ,:, :].ravel ())
1685
+ assert_equal (list (i ), a [0 , :, :].ravel ())
1686
1686
1687
1687
def test_iter_remove_multi_index_inner_loop ():
1688
1688
# Check that removing multi-index support works
@@ -1701,7 +1701,7 @@ def test_iter_remove_multi_index_inner_loop():
1701
1701
1702
1702
assert_equal (before , after )
1703
1703
assert_equal (i .ndim , 1 )
1704
- assert_raises (ValueError , lambda i :i .shape , i )
1704
+ assert_raises (ValueError , lambda i : i .shape , i )
1705
1705
assert_equal (i .itviews [0 ].shape , (24 ,))
1706
1706
1707
1707
# Removing the inner loop means there's just one iteration
@@ -1847,9 +1847,9 @@ def test_iter_buffering_delayed_alloc():
1847
1847
casting = 'unsafe' ,
1848
1848
op_dtypes = 'f4' )
1849
1849
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 )
1853
1853
1854
1854
def assign_iter (i ):
1855
1855
i [0 ] = 0
@@ -2240,7 +2240,7 @@ def test_iter_buffered_cast_subarray():
2240
2240
for x in i :
2241
2241
assert_equal (x ['a' ][:2 , 0 ], a [count ]['a' ][:, 0 ])
2242
2242
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 ])
2244
2244
count += 1
2245
2245
2246
2246
# matrix -> matrix (truncates and zero-pads)
@@ -2256,7 +2256,7 @@ def test_iter_buffered_cast_subarray():
2256
2256
for x in i :
2257
2257
assert_equal (x ['a' ][:2 , 0 ], a [count ]['a' ][:, 0 ])
2258
2258
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 ])
2260
2260
count += 1
2261
2261
2262
2262
def test_iter_buffering_badwriteback ():
@@ -2689,11 +2689,11 @@ def test_iter_buffering_reduction():
2689
2689
assert_equal (it [0 ], [1 , 2 , 1 , 2 ])
2690
2690
2691
2691
# 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 )
2693
2693
x [...] = np .arange (x .size ).reshape (x .shape )
2694
2694
y_base = np .arange (4 * 4 , dtype = np .int8 ).reshape (4 , 4 )
2695
2695
y_base_copy = y_base .copy ()
2696
- y = y_base [::2 ,:, None ]
2696
+ y = y_base [::2 , :, None ]
2697
2697
2698
2698
it = np .nditer ([y , x ],
2699
2699
['buffered' , 'external_loop' , 'reduce_ok' ],
@@ -3174,7 +3174,7 @@ def test_close_equivalent():
3174
3174
def add_close (x , y , out = None ):
3175
3175
addop = np .add
3176
3176
it = np .nditer ([x , y , out ], [],
3177
- [['readonly' ], ['readonly' ], ['writeonly' ,'allocate' ]])
3177
+ [['readonly' ], ['readonly' ], ['writeonly' , 'allocate' ]])
3178
3178
for (a , b , c ) in it :
3179
3179
addop (a , b , out = c )
3180
3180
ret = it .operands [2 ]
@@ -3184,7 +3184,7 @@ def add_close(x, y, out=None):
3184
3184
def add_context (x , y , out = None ):
3185
3185
addop = np .add
3186
3186
it = np .nditer ([x , y , out ], [],
3187
- [['readonly' ], ['readonly' ], ['writeonly' ,'allocate' ]])
3187
+ [['readonly' ], ['readonly' ], ['writeonly' , 'allocate' ]])
3188
3188
with it :
3189
3189
for (a , b , c ) in it :
3190
3190
addop (a , b , out = c )
0 commit comments