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

Method test_npy

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

Source from the content-addressed store, hash-verified

25
26class TestNumpyReader(unittest.TestCase):
27 def test_npy(self):
28 test_data = np.random.randint(0, 256, size=[3, 4, 4])
29 with tempfile.TemporaryDirectory() as tempdir:
30 filepath = os.path.join(tempdir, "test_data.npy")
31 np.save(filepath, test_data)
32
33 reader = NumpyReader()
34 result = reader.get_data(reader.read(filepath))
35 np.testing.assert_allclose(result[1]["spatial_shape"], test_data.shape)
36 np.testing.assert_allclose(result[0].shape, test_data.shape)
37 np.testing.assert_allclose(result[0], test_data)
38
39 def test_npz1(self):
40 test_data1 = np.random.randint(0, 256, size=[3, 4, 4])

Callers

nothing calls this directly

Calls 4

get_dataMethod · 0.95
readMethod · 0.95
NumpyReaderClass · 0.90
saveMethod · 0.80

Tested by

no test coverage detected