Skip to content

Commit b02077e

Browse files
committed
tst: add round-trip test to linear mappings
1 parent 8e50969 commit b02077e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

nitransforms/tests/test_linear.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,24 @@ def test_linear_to_x5(tmpdir, store_inverse):
286286
io.x5.to_filename("export3.x5", [node])
287287

288288

289-
def test_mapping_to_x5():
289+
@pytest.mark.parametrize("store_inverse", [True, False])
290+
def test_mapping_to_x5(tmp_path, store_inverse):
290291
mats = [
291292
np.eye(4),
292293
np.array([[1, 0, 0, 1], [0, 1, 0, 2], [0, 0, 1, 3], [0, 0, 0, 1]]),
293294
]
294295
mapping = nitl.LinearTransformsMapping(mats)
295-
node = mapping.to_x5()
296+
node = mapping.to_x5(
297+
metadata={"GeneratedBy": "FreeSurfer 8"}, store_inverse=store_inverse
298+
)
296299
assert node.array_length == 2
297300
assert node.transform.shape == (2, 4, 4)
298301

302+
mapping.to_filename(tmp_path / "export1.x5", x5_inverse=store_inverse)
303+
304+
# Test round trip
305+
assert mapping == nitl.Affine.from_filename(tmp_path / "export1.x5", fmt="X5")
306+
299307

300308
def test_mulmat_operator(testdata_path):
301309
"""Check the @ operator."""

0 commit comments

Comments
 (0)