def __init__(self, keys: KeysCollection) -> None: """ Args: keys: keys of the corresponding items to be transformed. See also: :py:class:`monai.transforms.compose.MapTransform` """ super().__init__(keys) self.identity = Identity()
def __init__(self, keys: KeysCollection, allow_missing_keys: bool = False) -> None: """ Args: keys: keys of the corresponding items to be transformed. See also: :py:class:`monai.transforms.compose.MapTransform` allow_missing_keys: don't raise exception if key is missing. """ super().__init__(keys, allow_missing_keys) self.identity = Identity()
def test_identity(self): img = self.imt identity = Identity() self.assertTrue(np.allclose(img, identity(img)))
def test_identity(self): for p in TEST_NDARRAYS: img = p(self.imt) identity = Identity() assert_allclose(img, identity(img))
from monailabel.interfaces.utils.transform import run_transforms, shape_info SHAPE_DATA = [ { "pred": np.array([[[1, 0, 1, 0], [0, 0, 1, 0], [0, 0, 1, 0]]]).astype(np.float32) }, ["pred"], "pred: (1, 3, 4)(float32)", ] TRANSFORM_DATA = [{ "pred": np.array([[[1, 0, 1, 0], [0, 0, 1, 0], [0, 0, 1, 0]]]).astype(np.float32) }, [Identity()]] class TestTransformUtils(unittest.TestCase): @parameterized.expand([SHAPE_DATA]) def test_shape_info(self, data, keys, expected_output): res = shape_info(data, keys) self.assertEqual(res, expected_output) @parameterized.expand([TRANSFORM_DATA]) def test_run_transforms(self, data, callables): res = run_transforms(data, callables) np.testing.assert_equal(res, data)