(self, _, spatial_axis)
| 28 | class TestRandFlipd(NumpyImageTestCase2D): |
| 29 | @parameterized.expand(VALID_CASES) |
| 30 | def test_correct_results(self, _, spatial_axis): |
| 31 | for p in TEST_NDARRAYS_ALL: |
| 32 | init_param = {"keys": "img", "prob": 1.0, "spatial_axis": spatial_axis} |
| 33 | flip = RandFlipd(**init_param) |
| 34 | im = p(self.imt[0]) |
| 35 | call_param = {"data": {"img": im}} |
| 36 | result = flip(**call_param) |
| 37 | |
| 38 | # test lazy |
| 39 | test_resampler_lazy(flip, result, init_param, call_param, output_key="img") |
| 40 | flip.lazy = False |
| 41 | |
| 42 | expected = [np.flip(channel, spatial_axis) for channel in self.imt[0]] |
| 43 | expected = np.stack(expected) |
| 44 | assert_allclose(result["img"], p(expected), type_test="tensor") |
| 45 | test_local_inversion(flip, {"img": result["img"]}, {"img": im}, "img") |
| 46 | |
| 47 | set_track_meta(False) |
| 48 | result = flip({"img": im})["img"] |
| 49 | self.assertNotIsInstance(result, MetaTensor) |
| 50 | self.assertIsInstance(result, torch.Tensor) |
| 51 | set_track_meta(True) |
| 52 | |
| 53 | |
| 54 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected