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

Function test_isVector

Wrapping/Python/tests/sitkNumpyArrayConversionTest.py:98–108  ·  view source on GitHub ↗

Test behavior of isVector option

(shape, is_vector, expected_size, expected_type, expected_components)

Source from the content-addressed store, hash-verified

96 ((2, 3, 5), True, (3, 2), sitk.sitkVectorFloat32, 5),
97])
98def test_isVector(shape, is_vector, expected_size, expected_type, expected_components):
99 """Test behavior of isVector option"""
100 nda = np.arange(np.prod(shape), dtype=np.float32).reshape(shape)
101 img = sitk.GetImageFromArray(nda, isVector=is_vector)
102
103 assert img.GetSize() == expected_size, f"Expected size {expected_size}, got {img.GetSize()}"
104 assert img.GetPixelID() == expected_type, f"Expected type {expected_type}, got {img.GetPixelID()}"
105
106 if expected_components is not None:
107 assert img.GetNumberOfComponentsPerPixel() == expected_components, \
108 f"Expected {expected_components} components, got {img.GetNumberOfComponentsPerPixel()}"
109
110
111def test_complex_image_to_numpy():

Callers

nothing calls this directly

Calls 3

GetSizeMethod · 0.45
GetPixelIDMethod · 0.45

Tested by

no test coverage detected