(self)
| 136 | assert_allclose(transform_inverse(out)["Y"].array, np.ones((1, 10, 16, 17)) * 2) |
| 137 | |
| 138 | def test_consistent_resize(self): |
| 139 | spatial_size = (16, 16, 16) |
| 140 | rescaler_1 = Resize(spatial_size=spatial_size, anti_aliasing=True, anti_aliasing_sigma=(0.5, 1.0, 2.0)) |
| 141 | rescaler_2 = Resize(spatial_size=spatial_size, anti_aliasing=True, anti_aliasing_sigma=None) |
| 142 | rescaler_dict = Resized( |
| 143 | keys=["img1", "img2"], |
| 144 | spatial_size=spatial_size, |
| 145 | anti_aliasing=(True, True), |
| 146 | anti_aliasing_sigma=[(0.5, 1.0, 2.0), None], |
| 147 | ) |
| 148 | test_input_1 = torch.randn([3, 32, 32, 32]) |
| 149 | test_input_2 = torch.randn([3, 32, 32, 32]) |
| 150 | test_input_dict = {"img1": test_input_1, "img2": test_input_2} |
| 151 | assert_allclose(rescaler_1(test_input_1), rescaler_dict(test_input_dict)["img1"]) |
| 152 | assert_allclose(rescaler_2(test_input_2), rescaler_dict(test_input_dict)["img2"]) |
| 153 | |
| 154 | |
| 155 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected