Esempio n. 1
0
    def test_fail(self):

        t1 = SpatialPadd("image", [10, 5])
        data = t1(self.all_data["2D"])

        # Check that error is thrown when inverse are used out of order.
        t2 = ResizeWithPadOrCropd("image", [10, 5])
        with self.assertRaises(RuntimeError):
            t2.inverse(data)
Esempio n. 2
0
 def test_pad_shape(self, input_param, input_data, expected_val):
     for p in TEST_NDARRAYS_ALL:
         if isinstance(
                 p(0),
                 torch.Tensor) and ("constant_values" in input_param
                                    or input_param["mode"] == "reflect"):
             continue
         padcropper = ResizeWithPadOrCropd(**input_param)
         input_data["img"] = p(input_data["img"])
         result = padcropper(input_data)
         np.testing.assert_allclose(result["img"].shape, expected_val)
         inv = padcropper.inverse(result)
         for k in input_data:
             self.assertTupleEqual(inv[k].shape, input_data[k].shape)