Skip to content

Commit bca0fcc

Browse files
committed
TST: test header read on V4 .PAR file for strict_sort=True too
1 parent bbc136e commit bca0fcc

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

nibabel/tests/test_parrec.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,22 @@ def test_top_level_load():
154154

155155
def test_header():
156156
v42_hdr = PARRECHeader(HDR_INFO, HDR_DEFS)
157-
with open(V4_PAR, 'rt') as fobj:
158-
v4_hdr = PARRECHeader.from_fileobj(fobj)
159-
with open(V41_PAR, 'rt') as fobj:
160-
v41_hdr = PARRECHeader.from_fileobj(fobj)
161-
for hdr in (v42_hdr, v41_hdr, v4_hdr):
162-
hdr = PARRECHeader(HDR_INFO, HDR_DEFS)
163-
assert_equal(hdr.get_data_shape(), (64, 64, 9, 3))
164-
assert_equal(hdr.get_data_dtype(), np.dtype('<u2'))
165-
assert_equal(hdr.get_zooms(), (3.75, 3.75, 8.0, 2.0))
166-
assert_equal(hdr.get_data_offset(), 0)
167-
si = np.array([np.unique(x) for x in hdr.get_data_scaling()]).ravel()
168-
assert_almost_equal(si, (1.2903541326522827, 0.0), 5)
169-
assert_equal(hdr.get_q_vectors(), None)
170-
assert_equal(hdr.get_bvals_bvecs(), (None, None))
157+
for strict_sort in [False, True]:
158+
with open(V4_PAR, 'rt') as fobj:
159+
v4_hdr = PARRECHeader.from_fileobj(fobj, strict_sort=strict_sort)
160+
with open(V41_PAR, 'rt') as fobj:
161+
v41_hdr = PARRECHeader.from_fileobj(fobj, strict_sort=strict_sort)
162+
for hdr in (v42_hdr, v41_hdr, v4_hdr):
163+
hdr = PARRECHeader(HDR_INFO, HDR_DEFS)
164+
assert_equal(hdr.get_data_shape(), (64, 64, 9, 3))
165+
assert_equal(hdr.get_data_dtype(), np.dtype('<u2'))
166+
assert_equal(hdr.get_zooms(), (3.75, 3.75, 8.0, 2.0))
167+
assert_equal(hdr.get_data_offset(), 0)
168+
si = np.array(
169+
[np.unique(x) for x in hdr.get_data_scaling()]).ravel()
170+
assert_almost_equal(si, (1.2903541326522827, 0.0), 5)
171+
assert_equal(hdr.get_q_vectors(), None)
172+
assert_equal(hdr.get_bvals_bvecs(), (None, None))
171173

172174

173175
def test_header_scaling():

0 commit comments

Comments
 (0)