MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / test_write_output_shape

Method test_write_output_shape

tests/data/test_png_rw.py:87–96  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

85 np.testing.assert_allclose(out, img_save_val)
86
87 def test_write_output_shape(self):
88 with tempfile.TemporaryDirectory() as out_dir:
89 image_name = os.path.join(out_dir, "test.png")
90 img = np.random.rand(2, 2, 3)
91 writer_obj = PILWriter(output_dtype=np.uint8)
92 writer_obj.set_data_array(img, channel_dim=-1)
93 writer_obj.set_metadata({"spatial_shape": (4, 4)}, scale=255)
94 writer_obj.write(image_name, format="PNG")
95 out = np.asarray(Image.open(image_name))
96 np.testing.assert_allclose(out.shape, (4, 4, 3))
97
98
99if __name__ == "__main__":

Callers

nothing calls this directly

Calls 4

set_data_arrayMethod · 0.95
set_metadataMethod · 0.95
writeMethod · 0.95
PILWriterClass · 0.90

Tested by

no test coverage detected