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

Method test_consistent_resize

tests/transforms/test_resized.py:138–152  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
155if __name__ == "__main__":

Callers

nothing calls this directly

Calls 3

ResizeClass · 0.90
ResizedClass · 0.90
assert_allcloseFunction · 0.90

Tested by

no test coverage detected