MCPcopy Create free account
hub / github.com/SimpleITK/SimpleITK / test_write_pathlib

Function test_write_pathlib

Wrapping/Python/tests/sitkImageReadWrite.py:56–75  ·  view source on GitHub ↗

Test writing images using pathlib.Path objects

(test_dir)

Source from the content-addressed store, hash-verified

54
55
56def test_write_pathlib(test_dir):
57 """Test writing images using pathlib.Path objects"""
58 # Test single image write
59 img = sitk.Image([32, 32], sitk.sitkUInt8)
60 img[10, 10] = 13
61 path = test_dir / "write_pathlib.mha"
62
63 sitk.WriteImage(img, path)
64 out = sitk.ReadImage(path)
65 assert sitk.Hash(img) == sitk.Hash(out), "Image hash mismatch after read/write"
66
67 # Test image series write
68 z_size = 3
69 path_list = [test_dir / f"write_pathlib_{i}.mha" for i in range(z_size)]
70 img = sitk.Image([32, 32, z_size], sitk.sitkUInt8)
71 sitk.WriteImage(img, path_list)
72
73 # Verify all files were created
74 for path in path_list:
75 assert path.exists(), f"Expected file {path} was not created"
76
77
78def test_write_procedure(test_dir):

Callers

nothing calls this directly

Calls 1

ImageMethod · 0.80

Tested by

no test coverage detected