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

Method test_read_list

tests/data/test_nrrd_reader.py:86–97  ·  view source on GitHub ↗
(self, data_shape, filenames, expected_shape, dtype)

Source from the content-addressed store, hash-verified

84
85 @parameterized.expand([TEST_CASE_7])
86 def test_read_list(self, data_shape, filenames, expected_shape, dtype):
87 test_image = np.random.rand(*data_shape).astype(dtype)
88 with tempfile.TemporaryDirectory() as tempdir:
89 for i, filename in enumerate(filenames):
90 filenames[i] = os.path.join(tempdir, filename)
91 nrrd.write(filenames[i], test_image.astype(dtype))
92 reader = NrrdReader()
93 results = reader.read(filenames)
94 for result in results:
95 self.assertTupleEqual(result.array.shape, expected_shape)
96 self.assertTupleEqual(tuple(result.header["sizes"]), expected_shape)
97 np.testing.assert_allclose(result.array, test_image)
98
99 @parameterized.expand([TEST_CASE_8])
100 def test_read_with_header(self, data_shape, filename, expected_shape, dtype, reference_header):

Callers

nothing calls this directly

Calls 4

readMethod · 0.95
NrrdReaderClass · 0.90
astypeMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected