Skip to content

Commit 27ef400

Browse files
committed
fixed style and convetion in test_io.py
1 parent 1987f79 commit 27ef400

File tree

1 file changed

+19
-38
lines changed

1 file changed

+19
-38
lines changed

nibabel/freesurfer/tests/test_io.py

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,8 @@
3636
data_path = pjoin(nib_data, 'nitest-freesurfer', DATA_SDIR)
3737
have_freesurfer = isdir(data_path)
3838

39-
<<<<<<< HEAD
40-
freesurfer_test = pytest.mark.skipif(not have_freesurfer, reason='cannot find freesurfer {0} directory'.format(DATA_SDIR))
41-
=======
4239
freesurfer_test = pytest.mark.skipif(not have_freesurfer,
4340
reason='cannot find freesurfer {0} directory'.format(DATA_SDIR))
44-
>>>>>>> 2fb977b1605f5a4c4394f3b1b694e0a5e8f66de5
4541

4642
def _hash_file_content(fname):
4743
hasher = hashlib.md5()
@@ -64,17 +60,10 @@ def test_geometry():
6460
surf_path, read_metadata=True, read_stamp=True)
6561

6662
assert 0 == faces.min()
67-
<<<<<<< HEAD
68-
assert coords.shape[0] == (faces.max() + 1)
69-
assert 9 == len(volume_info)
70-
# assert np.array_equal([2, 0, 20],volume_info['head'])
71-
np.testing.assert_array_equal([2, 0, 20],volume_info['head'])
72-
=======
7363
assert coords.shape[0] == faces.max() + 1
7464
assert 9 == len(volume_info)
7565
assert np.array_equal([2, 0, 20], volume_info['head'])
76-
>>>>>>> 2fb977b1605f5a4c4394f3b1b694e0a5e8f66de5
77-
assert create_stamp == ['created by greve on Thu Jun 8 19:17:51 2006'] # this creates assertion error - should we just remove it?
66+
assert create_stamp == 'created by greve on Thu Jun 8 19:17:51 2006'
7867

7968
# Test equivalence of freesurfer- and nibabel-generated triangular files
8069
# with respect to read_geometry()
@@ -91,12 +80,8 @@ def test_geometry():
9180
for key in ('xras', 'yras', 'zras', 'cras'):
9281
assert_allclose(volume_info2[key], volume_info[key],
9382
rtol=1e-7, atol=1e-30)
94-
<<<<<<< HEAD
95-
#assert.array_equal(volume_info2['cras'], volume_info['cras'])
96-
np.testing.assert_array_equal(volume_info2['cras'], volume_info['cras'])
97-
=======
83+
9884
assert np.array_equal(volume_info2['cras'], volume_info['cras'])
99-
>>>>>>> 2fb977b1605f5a4c4394f3b1b694e0a5e8f66de5
10085
with open(surf_path, 'rb') as fobj:
10186
np.fromfile(fobj, ">u1", 3)
10287
read_create_stamp = fobj.readline().decode().rstrip('\n')
@@ -106,28 +91,31 @@ def test_geometry():
10691
with clear_and_catch_warnings() as w:
10792
warnings.filterwarnings('always', category=DeprecationWarning)
10893
read_geometry(surf_path, read_metadata=True)
109-
assert(any('volume information contained' in str(ww.message)
94+
95+
assert(
96+
any('volume information contained' in str(ww.message)
11097
for ww in w))
111-
assert(any('extension code' in str(ww.message) for ww in w))
98+
assert(
99+
any('extension code' in str(ww.message) for ww in w))
112100
volume_info['head'] = [1, 2]
113101
with clear_and_catch_warnings() as w:
114102
write_geometry(surf_path, coords, faces, create_stamp, volume_info)
115-
assert(any('Unknown extension' in str(ww.message) for ww in w))
103+
assert(
104+
any('Unknown extension' in str(ww.message) for ww in w))
116105
volume_info['a'] = 0
117106
with pytest.raises(ValueError):
118107
write_geometry(surf_path, coords, faces, create_stamp, volume_info)
119-
120108

121109
assert create_stamp == read_create_stamp
122110

123-
np.testing.assert_array_equal(coords, coords2)
124-
np.testing.assert_array_equal(faces, faces2)
111+
assert np.array_equal(coords, coords2)
112+
assert np.array_equal(faces, faces2)
125113

126114
# Validate byte ordering
127115
coords_swapped = coords.byteswap().newbyteorder()
128116
faces_swapped = faces.byteswap().newbyteorder()
129-
np.testing.assert_array_equal(coords_swapped, coords)
130-
np.testing.assert_array_equal(faces_swapped, faces)
117+
assert np.array_equal(coords_swapped, coords)
118+
assert np.array_equal(faces_swapped, faces)
131119

132120

133121
@freesurfer_test
@@ -171,11 +159,8 @@ def test_write_morph_data():
171159
for shape in okay_shapes:
172160
write_morph_data('test.curv', values.reshape(shape))
173161
# Check ordering is preserved, regardless of shape
174-
<<<<<<< HEAD
175-
assert np.array_equal(read_morph_data('test.curv') ,values)
176-
=======
177162
assert np.array_equal(read_morph_data('test.curv'), values)
178-
>>>>>>> 2fb977b1605f5a4c4394f3b1b694e0a5e8f66de5
163+
179164
with pytest.raises(ValueError):
180165
write_morph_data('test.curv', np.zeros(shape), big_num)
181166
# Windows 32-bit overflows Python int
@@ -185,10 +170,6 @@ def test_write_morph_data():
185170
for shape in bad_shapes:
186171
with pytest.raises(ValueError):
187172
write_morph_data('test.curv', values.reshape(shape))
188-
<<<<<<< HEAD
189-
190-
=======
191-
>>>>>>> 2fb977b1605f5a4c4394f3b1b694e0a5e8f66de5
192173

193174
@freesurfer_test
194175
def test_annot():
@@ -225,10 +206,10 @@ def test_annot():
225206
if labels_orig is not None:
226207
labels_orig_2, _, _ = read_annot(annot_path, orig_ids=True)
227208

228-
np.testing.assert_array_equal(labels, labels2)
209+
assert np.array_equal(labels, labels2)
229210
if labels_orig is not None:
230-
np.testing.assert_array_equal(labels_orig, labels_orig_2)
231-
np.testing.assert_array_equal(ctab, ctab2)
211+
assert np.array_equal(labels_orig, labels_orig_2)
212+
assert np.array_equal(ctab, ctab2)
232213
assert names == names2
233214

234215

@@ -393,6 +374,6 @@ def test_write_annot_maxstruct():
393374
# Validate the file can be read
394375
rt_labels, rt_ctab, rt_names = read_annot(annot_path)
395376
# Check round-trip
396-
assert_array_equal(labels, rt_labels)
397-
assert_array_equal(rgba, rt_ctab[:, :4])
377+
assert np.array_equal(labels, rt_labels)
378+
assert np.array_equal(rgba, rt_ctab[:, :4])
398379
assert names == [n.decode('ascii') for n in rt_names]

0 commit comments

Comments
 (0)