| Total Complexity | 11 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import numpy as np |
||
| 2 | from torchio.transforms import RandomDownsample |
||
| 3 | from ...utils import TorchioTestCase |
||
| 4 | |||
| 5 | |||
| 6 | class TestRandomDownsample(TorchioTestCase): |
||
| 7 | """Tests for `RandomDownsample`.""" |
||
| 8 | |||
| 9 | def test_downsample(self): |
||
| 10 | transform = RandomDownsample( |
||
| 11 | axes=1, |
||
| 12 | downsampling=(2., 2.) |
||
| 13 | ) |
||
| 14 | transformed = transform(self.sample) |
||
| 15 | self.assertEqual(self.sample.spacing[1] * 2, transformed.spacing[1]) |
||
| 16 | |||
| 17 | def test_out_of_range_axis(self): |
||
| 18 | with self.assertRaises(ValueError): |
||
| 19 | RandomDownsample(axes=3) |
||
| 20 | |||
| 21 | def test_out_of_range_axis_in_tuple(self): |
||
| 22 | with self.assertRaises(ValueError): |
||
| 23 | RandomDownsample(axes=(0, -1, 2)) |
||
| 24 | |||
| 25 | def test_wrong_axes_type(self): |
||
| 26 | with self.assertRaises(ValueError): |
||
| 27 | RandomDownsample(axes='wrong') |
||
| 28 | |||
| 29 | def test_wrong_downsampling_type(self): |
||
| 30 | with self.assertRaises(ValueError): |
||
| 31 | RandomDownsample(downsampling='wrong') |
||
| 32 | |||
| 33 | def test_below_one_downsampling(self): |
||
| 34 | with self.assertRaises(ValueError): |
||
| 35 | RandomDownsample(downsampling=0.2) |
||
| 36 |