MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / test_npz3

Method test_npz3

tests/data/test_numpy_reader.py:64–75  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

62 np.testing.assert_allclose(result[0], np.stack([test_data1, test_data2]))
63
64 def test_npz3(self):
65 test_data1 = np.random.randint(0, 256, size=[3, 4, 4])
66 test_data2 = np.random.randint(0, 256, size=[3, 4, 4])
67 with tempfile.TemporaryDirectory() as tempdir:
68 filepath = os.path.join(tempdir, "test_data.npz")
69 np.savez(filepath, test1=test_data1, test2=test_data2)
70
71 reader = NumpyReader(npz_keys=["test1", "test2"])
72 result = reader.get_data(reader.read(filepath))
73 np.testing.assert_allclose(result[1]["spatial_shape"], test_data1.shape)
74 np.testing.assert_allclose(result[0].shape, (2, 3, 4, 4))
75 np.testing.assert_allclose(result[0], np.stack([test_data1, test_data2]))
76
77 def test_npy_pickle(self):
78 test_data = {"test": np.random.randint(0, 256, size=[3, 4, 4])}

Callers

nothing calls this directly

Calls 3

get_dataMethod · 0.95
readMethod · 0.95
NumpyReaderClass · 0.90

Tested by

no test coverage detected