Skip to content

Commit 563ec5b

Browse files
MAINT: apply ruff/Pycodestyle rule E701
E701 Multiple statements on one line (colon)
1 parent 3f3e6f2 commit 563ec5b

File tree

13 files changed

+58
-29
lines changed

13 files changed

+58
-29
lines changed

numpy/_core/tests/test_arrayprint.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def test_nan_inf(self):
1919
assert_equal(repr(x), 'array([nan, inf])')
2020

2121
def test_subclass(self):
22-
class sub(np.ndarray): pass
22+
class sub(np.ndarray):
23+
pass
2324

2425
# one dimensional
2526
x1d = np.array([1, 2]).view(sub)

numpy/_core/tests/test_multiarray.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9725,7 +9725,8 @@ def __array_finalize__(self, obj):
97259725
raise Exception(self)
97269726

97279727
# a plain object can't be weakref'd
9728-
class Dummy: pass
9728+
class Dummy:
9729+
pass
97299730

97309731
# get a weak reference to an object within an array
97319732
obj_arr = np.array(Dummy())

numpy/_core/tests/test_umath.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4760,7 +4760,8 @@ def test_signaling_nan_exceptions():
47604760
])
47614761
def test_outer_subclass_preserve(arr):
47624762
# for gh-8661
4763-
class foo(np.ndarray): pass
4763+
class foo(np.ndarray):
4764+
pass
47644765
actual = np.multiply.outer(arr.view(foo), arr.view(foo))
47654766
assert actual.__class__.__name__ == 'foo'
47664767

numpy/ma/tests/test_core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5435,7 +5435,8 @@ def test_coercion_bytes(self):
54355435

54365436
def test_subclass(self):
54375437
# https://github.com/astropy/astropy/issues/6645
5438-
class Sub(type(np.ma.masked)): pass
5438+
class Sub(type(np.ma.masked)):
5439+
pass
54395440

54405441
a = Sub()
54415442
assert_(a is Sub())

numpy/matrixlib/defmatrix.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ def __new__(subtype, data, dtype=None, copy=True):
137137
new = data.view(subtype)
138138
if intype != data.dtype:
139139
return new.astype(intype)
140-
if copy: return new.copy()
141-
else: return new
140+
if copy:
141+
return new.copy()
142+
else:
143+
return new
142144

143145
if isinstance(data, str):
144146
data = _convert_from_string(data)
@@ -169,7 +171,8 @@ def __new__(subtype, data, dtype=None, copy=True):
169171

170172
def __array_finalize__(self, obj):
171173
self._getitem = False
172-
if (isinstance(obj, matrix) and obj._getitem): return
174+
if (isinstance(obj, matrix) and obj._getitem):
175+
return
173176
ndim = self.ndim
174177
if (ndim == 2):
175178
return

tools/swig/test/testArray.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def testConstructor2(self):
3939

4040
def testConstructor3(self):
4141
"Test Array1 copy constructor"
42-
for i in range(self.array1.length()): self.array1[i] = i
42+
for i in range(self.array1.length()):
43+
self.array1[i] = i
4344
arrayCopy = Array.Array1(self.array1)
4445
self.assertTrue(arrayCopy == self.array1)
4546

@@ -97,17 +98,20 @@ def testGetBad2(self):
9798

9899
def testAsString(self):
99100
"Test Array1 asString method"
100-
for i in range(self.array1.length()): self.array1[i] = i+1
101+
for i in range(self.array1.length()):
102+
self.array1[i] = i+1
101103
self.assertTrue(self.array1.asString() == "[ 1, 2, 3, 4, 5 ]")
102104

103105
def testStr(self):
104106
"Test Array1 __str__ method"
105-
for i in range(self.array1.length()): self.array1[i] = i-2
107+
for i in range(self.array1.length()):
108+
self.array1[i] = i-2
106109
self.assertTrue(str(self.array1) == "[ -2, -1, 0, 1, 2 ]")
107110

108111
def testView(self):
109112
"Test Array1 view method"
110-
for i in range(self.array1.length()): self.array1[i] = i+1
113+
for i in range(self.array1.length()):
114+
self.array1[i] = i+1
111115
a = self.array1.view()
112116
self.assertTrue(isinstance(a, np.ndarray))
113117
self.assertTrue(len(a) == self.length)
@@ -289,7 +293,8 @@ def testConstructor2(self):
289293

290294
def testConstructor3(self):
291295
"Test ArrayZ copy constructor"
292-
for i in range(self.array3.length()): self.array3[i] = complex(i,-i)
296+
for i in range(self.array3.length()):
297+
self.array3[i] = complex(i, -i)
293298
arrayCopy = Array.ArrayZ(self.array3)
294299
self.assertTrue(arrayCopy == self.array3)
295300

@@ -347,17 +352,20 @@ def testGetBad2(self):
347352

348353
def testAsString(self):
349354
"Test ArrayZ asString method"
350-
for i in range(self.array3.length()): self.array3[i] = complex(i+1,-i-1)
355+
for i in range(self.array3.length()):
356+
self.array3[i] = complex(i+1, -i-1)
351357
self.assertTrue(self.array3.asString() == "[ (1,-1), (2,-2), (3,-3), (4,-4), (5,-5) ]")
352358

353359
def testStr(self):
354360
"Test ArrayZ __str__ method"
355-
for i in range(self.array3.length()): self.array3[i] = complex(i-2,(i-2)*2)
361+
for i in range(self.array3.length()):
362+
self.array3[i] = complex(i-2, (i-2)*2)
356363
self.assertTrue(str(self.array3) == "[ (-2,-4), (-1,-2), (0,0), (1,2), (2,4) ]")
357364

358365
def testView(self):
359366
"Test ArrayZ view method"
360-
for i in range(self.array3.length()): self.array3[i] = complex(i+1,i+2)
367+
for i in range(self.array3.length()):
368+
self.array3[i] = complex(i+1, i+2)
361369
a = self.array3.view()
362370
self.assertTrue(isinstance(a, np.ndarray))
363371
self.assertTrue(len(a) == self.length)

tools/swig/test/testFarray.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
# Import NumPy
99
import numpy as np
1010
major, minor = [ int(d) for d in np.__version__.split(".")[:2] ]
11-
if major == 0: BadListError = TypeError
12-
else: BadListError = ValueError
11+
if major == 0:
12+
BadListError = TypeError
13+
else:
14+
BadListError = ValueError
1315

1416
# Add the distutils-generated build directory to the python search path and then
1517
# import the extension module

tools/swig/test/testFlat.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
# Import NumPy
99
import numpy as np
1010
major, minor = [ int(d) for d in np.__version__.split(".")[:2] ]
11-
if major == 0: BadListError = TypeError
12-
else: BadListError = ValueError
11+
if major == 0:
12+
BadListError = TypeError
13+
else:
14+
BadListError = ValueError
1315

1416
import Flat
1517

tools/swig/test/testFortran.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
# Import NumPy
77
import numpy as np
88
major, minor = [ int(d) for d in np.__version__.split(".")[:2] ]
9-
if major == 0: BadListError = TypeError
10-
else: BadListError = ValueError
9+
if major == 0:
10+
BadListError = TypeError
11+
else:
12+
BadListError = ValueError
1113

1214
import Fortran
1315

tools/swig/test/testMatrix.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
# Import NumPy
77
import numpy as np
88
major, minor = [ int(d) for d in np.__version__.split(".")[:2] ]
9-
if major == 0: BadListError = TypeError
10-
else: BadListError = ValueError
9+
if major == 0:
10+
BadListError = TypeError
11+
else:
12+
BadListError = ValueError
1113

1214
import Matrix
1315

0 commit comments

Comments
 (0)