Skip to content

Commit d8504c6

Browse files
author
Ben Cipollini
committed
STY: autopep8 on test code.
1 parent 469fbd9 commit d8504c6

Some content is hidden

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

63 files changed

+1484
-1378
lines changed

nibabel/freesurfer/tests/test_mghformat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
v2r = np.array([[1, 2, 3, -13], [2, 3, 1, -11.5],
3838
[3, 1, 2, -11.5], [0, 0, 0, 1]], dtype=np.float32)
3939
# sample voxel to ras - tkr matrix (mri_info --vox2ras-tkr)
40-
v2rtkr = np.array([[-1.0, 0.0, 0.0, 1.5],
40+
v2rtkr = np.array([[-1.0, 0.0, 0.0, 1.5],
4141
[0.0, 0.0, 1.0, -2.5],
4242
[0.0, -1.0, 0.0, 2.0],
4343
[0.0, 0.0, 0.0, 1.0]], dtype=np.float32)

nibabel/gifti/tests/test_gifti.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_gifti_image():
2424
# arguments.
2525
gi = GiftiImage()
2626
assert_equal(gi.darrays, [])
27-
arr = np.zeros((2,3))
27+
arr = np.zeros((2, 3))
2828
gi.darrays.append(arr)
2929
# Now check we didn't overwrite the default arg
3030
gi = GiftiImage()
@@ -63,9 +63,9 @@ def test_gifti_image():
6363
def test_dataarray():
6464
for dt_code in data_type_codes.value_set():
6565
data_type = data_type_codes.type[dt_code]
66-
if data_type is np.void: # not supported
66+
if data_type is np.void: # not supported
6767
continue
68-
arr = np.zeros((10,3), dtype=data_type)
68+
arr = np.zeros((10, 3), dtype=data_type)
6969
da = GiftiDataArray.from_array(arr, 'triangle')
7070
assert_equal(da.datatype, data_type_codes[arr.dtype])
7171
bs_arr = arr.byteswap().newbyteorder()
@@ -142,7 +142,7 @@ def assign_rgba(gl, val):
142142

143143
def test_print_summary():
144144
for fil in [DATA_FILE1, DATA_FILE2, DATA_FILE3, DATA_FILE4,
145-
DATA_FILE5, DATA_FILE6]:
145+
DATA_FILE5, DATA_FILE6]:
146146
gimg = nib.load(fil)
147147
gimg.print_summary()
148148

nibabel/gifti/tests/test_giftiio.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020

2121
class TestGiftiIO(object):
22+
2223
def setUp(self):
2324
with clear_and_catch_warnings() as w:
2425
warnings.simplefilter('always', DeprecationWarning)

nibabel/gifti/tests/test_parse_gifti_fast.py

Lines changed: 57 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -45,56 +45,56 @@
4545
numDA = [2, 1, 1, 1, 2, 1]
4646

4747
DATA_FILE1_darr1 = np.array(
48-
[[-16.07201 , -66.187515, 21.266994],
49-
[-16.705893, -66.054337, 21.232786],
50-
[-17.614349, -65.401642, 21.071466]])
51-
DATA_FILE1_darr2 = np.array( [0,1,2] )
52-
53-
DATA_FILE2_darr1 = np.array([[ 0.43635699],
54-
[ 0.270017 ],
55-
[ 0.133239 ],
56-
[ 0.35054299],
57-
[ 0.26538199],
58-
[ 0.32122701],
59-
[ 0.23495001],
60-
[ 0.26671499],
61-
[ 0.306851 ],
62-
[ 0.36302799]], dtype=np.float32)
48+
[[-16.07201, -66.187515, 21.266994],
49+
[-16.705893, -66.054337, 21.232786],
50+
[-17.614349, -65.401642, 21.071466]])
51+
DATA_FILE1_darr2 = np.array([0, 1, 2])
52+
53+
DATA_FILE2_darr1 = np.array([[0.43635699],
54+
[0.270017],
55+
[0.133239],
56+
[0.35054299],
57+
[0.26538199],
58+
[0.32122701],
59+
[0.23495001],
60+
[0.26671499],
61+
[0.306851],
62+
[0.36302799]], dtype=np.float32)
6363

6464
DATA_FILE3_darr1 = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0])
6565

6666
DATA_FILE4_darr1 = np.array([[-0.57811606],
67-
[-0.53871965],
68-
[-0.44602534],
69-
[-0.56532663],
70-
[-0.51392376],
71-
[-0.43225467],
72-
[-0.54646534],
73-
[-0.48011276],
74-
[-0.45624232],
75-
[-0.31101292]], dtype=np.float32)
76-
77-
DATA_FILE5_darr1 = np.array([[ 155.17539978, 135.58103943, 98.30715179],
78-
[ 140.33973694, 190.0491333 , 73.24776459],
79-
[ 157.3598938 , 196.97969055, 83.65809631],
80-
[ 171.46174622, 137.43661499, 78.4709549 ],
81-
[ 148.54592896, 97.06752777, 65.96373749],
82-
[ 123.45701599, 111.46841431, 66.3571167 ],
83-
[ 135.30892944, 202.28720093, 36.38148499],
84-
[ 178.28155518, 162.59469604, 37.75128937],
85-
[ 178.11087036, 115.28820038, 57.17986679],
86-
[ 142.81582642, 82.82115173, 31.02205276]], dtype=np.float32)
87-
88-
DATA_FILE5_darr2 = np.array([[ 6402, 17923, 25602],
89-
[14085, 25602, 17923],
90-
[25602, 14085, 4483],
91-
[17923, 1602, 14085],
92-
[ 4483, 25603, 25602],
93-
[25604, 25602, 25603],
94-
[25602, 25604, 6402],
95-
[25603, 3525, 25604],
96-
[ 1123, 17922, 12168],
97-
[25604, 12168, 17922]], dtype=np.int32)
67+
[-0.53871965],
68+
[-0.44602534],
69+
[-0.56532663],
70+
[-0.51392376],
71+
[-0.43225467],
72+
[-0.54646534],
73+
[-0.48011276],
74+
[-0.45624232],
75+
[-0.31101292]], dtype=np.float32)
76+
77+
DATA_FILE5_darr1 = np.array([[155.17539978, 135.58103943, 98.30715179],
78+
[140.33973694, 190.0491333, 73.24776459],
79+
[157.3598938, 196.97969055, 83.65809631],
80+
[171.46174622, 137.43661499, 78.4709549],
81+
[148.54592896, 97.06752777, 65.96373749],
82+
[123.45701599, 111.46841431, 66.3571167],
83+
[135.30892944, 202.28720093, 36.38148499],
84+
[178.28155518, 162.59469604, 37.75128937],
85+
[178.11087036, 115.28820038, 57.17986679],
86+
[142.81582642, 82.82115173, 31.02205276]], dtype=np.float32)
87+
88+
DATA_FILE5_darr2 = np.array([[6402, 17923, 25602],
89+
[14085, 25602, 17923],
90+
[25602, 14085, 4483],
91+
[17923, 1602, 14085],
92+
[4483, 25603, 25602],
93+
[25604, 25602, 25603],
94+
[25602, 25604, 6402],
95+
[25603, 3525, 25604],
96+
[1123, 17922, 12168],
97+
[25604, 12168, 17922]], dtype=np.int32)
9898

9999
DATA_FILE6_darr1 = np.array([9182740, 9182740, 9182740], dtype=np.float32)
100100

@@ -107,15 +107,15 @@ def test_read_ordering():
107107
assert_equal(img2.darrays[0].data.shape, (143479, 1))
108108
# Read image for which we know output shape
109109
img = load(DATA_FILE1)
110-
assert_equal(img.darrays[0].data.shape, (3,3))
110+
assert_equal(img.darrays[0].data.shape, (3, 3))
111111

112112

113113
def test_load_metadata():
114114
for i, dat in enumerate(datafiles):
115115
img = load(dat)
116116
me = img.meta
117117
assert_equal(numDA[i], img.numDA)
118-
assert_equal(img.version,'1.0')
118+
assert_equal(img.version, '1.0')
119119

120120

121121
def test_metadata_deprecations():
@@ -142,13 +142,15 @@ def test_load_dataarray1():
142142
for img in (img1, bimg):
143143
assert_array_almost_equal(img.darrays[0].data, DATA_FILE1_darr1)
144144
assert_array_almost_equal(img.darrays[1].data, DATA_FILE1_darr2)
145-
me=img.darrays[0].meta.metadata
145+
me = img.darrays[0].meta.metadata
146146
assert_true('AnatomicalStructurePrimary' in me)
147147
assert_true('AnatomicalStructureSecondary' in me)
148148
assert_equal(me['AnatomicalStructurePrimary'], 'CortexLeft')
149-
assert_array_almost_equal(img.darrays[0].coordsys.xform, np.eye(4,4))
150-
assert_equal(xform_codes.niistring[img.darrays[0].coordsys.dataspace],'NIFTI_XFORM_TALAIRACH')
151-
assert_equal(xform_codes.niistring[img.darrays[0].coordsys.xformspace],'NIFTI_XFORM_TALAIRACH')
149+
assert_array_almost_equal(img.darrays[0].coordsys.xform, np.eye(4, 4))
150+
assert_equal(xform_codes.niistring[img.darrays[
151+
0].coordsys.dataspace], 'NIFTI_XFORM_TALAIRACH')
152+
assert_equal(xform_codes.niistring[img.darrays[
153+
0].coordsys.xformspace], 'NIFTI_XFORM_TALAIRACH')
152154

153155

154156
def test_load_dataarray2():
@@ -223,19 +225,19 @@ def test_readwritedata():
223225
with InTemporaryDirectory():
224226
save(img, 'test.gii')
225227
img2 = load('test.gii')
226-
assert_equal(img.numDA,img2.numDA)
228+
assert_equal(img.numDA, img2.numDA)
227229
assert_array_almost_equal(img.darrays[0].data,
228230
img2.darrays[0].data)
229231

230232

231233
def test_write_newmetadata():
232234
img = gi.GiftiImage()
233-
attr = gi.GiftiNVPairs(name = 'mykey', value = 'val1')
235+
attr = gi.GiftiNVPairs(name='mykey', value='val1')
234236
newmeta = gi.GiftiMetaData(attr)
235237
img.meta = newmeta
236238
myme = img.meta.metadata
237239
assert_true('mykey' in myme)
238-
newmeta = gi.GiftiMetaData.from_dict( {'mykey1' : 'val2'} )
240+
newmeta = gi.GiftiMetaData.from_dict({'mykey1': 'val2'})
239241
img.meta = newmeta
240242
myme = img.meta.metadata
241243
assert_true('mykey1' in myme)

nibabel/nicom/tests/data_pkgs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
from ... import data as nibd
44

55
PUBLIC_PKG_DEF = dict(
6-
relpath = 'nipy/dicom/public',
7-
name = 'nipy-dicom-public',
8-
version = '0.1')
6+
relpath='nipy/dicom/public',
7+
name='nipy-dicom-public',
8+
version='0.1')
99

1010
PRIVATE_PKG_DEF = dict(
11-
relpath = 'nipy/dicom/private',
12-
name = 'nipy-dicom-private',
13-
version = '0.1')
11+
relpath='nipy/dicom/private',
12+
name='nipy-dicom-private',
13+
version='0.1')
1414

1515

1616
PUBLIC_DS = nibd.datasource_or_bomber(PUBLIC_PKG_DEF)

nibabel/nicom/tests/test_csareader.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
@dicom_test
2626
def test_csa_header_read():
2727
hdr = csa.get_csa_header(DATA, 'image')
28-
assert_equal(hdr['n_tags'],83)
29-
assert_equal(csa.get_csa_header(DATA,'series')['n_tags'],65)
30-
assert_raises(ValueError, csa.get_csa_header, DATA,'xxxx')
28+
assert_equal(hdr['n_tags'], 83)
29+
assert_equal(csa.get_csa_header(DATA, 'series')['n_tags'], 65)
30+
assert_raises(ValueError, csa.get_csa_header, DATA, 'xxxx')
3131
assert_true(csa.is_mosaic(hdr))
3232
# Get a shallow copy of the data, lacking the CSA marker
3333
# Need to do it this way because del appears broken in pydicom 0.9.7
@@ -94,7 +94,7 @@ def test_csa_params():
9494
snv = csa.get_slice_normal(csa_info)
9595
assert_equal(snv.shape, (3,))
9696
assert_true(np.allclose(1,
97-
np.sqrt((snv * snv).sum())))
97+
np.sqrt((snv * snv).sum())))
9898
amt = csa.get_acq_mat_txt(csa_info)
9999
assert_equal(amt, '128p*128')
100100
csa_info = csa.read(CSA2_B0)
@@ -106,7 +106,7 @@ def test_csa_params():
106106
assert_equal(g_vector, None)
107107
csa_info = csa.read(CSA2_B1000)
108108
b_matrix = csa.get_b_matrix(csa_info)
109-
assert_equal(b_matrix.shape, (3,3))
109+
assert_equal(b_matrix.shape, (3, 3))
110110
# check (by absence of error) that the B matrix is positive
111111
# semi-definite.
112112
q = dwp.B2q(b_matrix)
@@ -122,10 +122,10 @@ def test_ice_dims():
122122
ex_dims0 = ['X', '1', '1', '1', '1', '1', '1',
123123
'48', '1', '1', '1', '1', '201']
124124
ex_dims1 = ['X', '1', '1', '1', '2', '1', '1',
125-
'48', '1', '1', '1', '1', '201']
125+
'48', '1', '1', '1', '1', '201']
126126
for csa_str, ex_dims in ((CSA2_B0, ex_dims0),
127127
(CSA2_B1000, ex_dims1)):
128128
csa_info = csa.read(csa_str)
129129
assert_equal(csa.get_ice_dims(csa_info),
130-
ex_dims)
130+
ex_dims)
131131
assert_equal(csa.get_ice_dims({}), None)

nibabel/nicom/tests/test_dicomreaders.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616

1717
from numpy.testing import assert_array_equal, assert_array_almost_equal
1818

19+
1920
@dicom_test
2021
def test_read_dwi():
2122
img = didr.mosaic_to_nii(DATA)
2223
arr = img.get_data()
23-
assert_equal(arr.shape, (128,128,48))
24+
assert_equal(arr.shape, (128, 128, 48))
2425
assert_array_almost_equal(img.affine, EXPECTED_AFFINE)
2526

2627

0 commit comments

Comments
 (0)