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

Method test_npy_pickle

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

Source from the content-addressed store, hash-verified

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])}
79 with tempfile.TemporaryDirectory() as tempdir:
80 filepath = os.path.join(tempdir, "test_data.npy")
81 np.save(filepath, test_data, allow_pickle=True)
82
83 reader = NumpyReader()
84
85 with self.assertRaises(ValueError):
86 reader.get_data(reader.read(filepath))
87
88 reader = NumpyReader(allow_pickle=True)
89 result = reader.get_data(reader.read(filepath))[0].item()
90
91 np.testing.assert_allclose(result["test"].shape, test_data["test"].shape)
92 np.testing.assert_allclose(result["test"], test_data["test"])
93
94 def test_kwargs(self):
95 test_data = {"test": 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