Skip to content

Commit d9e74f7

Browse files
committed
enh: final pushes to coverage of this PR
1 parent fbee5c0 commit d9e74f7

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

nitransforms/io/itk.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,7 @@ def to_string(self):
202202
@classmethod
203203
def from_binary(cls, byte_stream):
204204
"""Read the struct from a matlab binary file."""
205-
mdict = _read_mat(byte_stream)
206-
nxforms = mdict['fixed'].shape[0]
207-
208-
_self = cls()
209-
_self.xforms = [ITKLinearTransform.from_matlab_dict(mdict, i)
210-
for i in range(nxforms)]
211-
return _self
205+
raise TransformFileError('Please use the ITK\'s new .h5 format.')
212206

213207
@classmethod
214208
def from_fileobj(cls, fileobj, check=True):

nitransforms/tests/test_io.py

+8
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,17 @@ def test_ITKLinearTransformArray(tmpdir, data_path):
133133
assert np.allclose(xfm.structarr['parameters'][:3, ...],
134134
xfm2.structarr['parameters'][:3, ...])
135135

136+
# ITK does not handle transforms lists in Matlab format
136137
with pytest.raises(TransformFileError):
137138
itklist.to_filename('matlablist.mat')
138139

140+
with pytest.raises(TransformFileError):
141+
xfm2 = itk.ITKLinearTransformArray.from_binary({})
142+
143+
with open('filename.mat', 'ab') as f:
144+
with pytest.raises(TransformFileError):
145+
xfm2 = itk.ITKLinearTransformArray.from_fileobj(f)
146+
139147

140148
@pytest.mark.parametrize('matlab_ver', ['4', '5'])
141149
def test_read_mat1(tmpdir, matlab_ver):

0 commit comments

Comments
 (0)