Passed
Pull Request — master (#353)
by Fernando
01:16
created

TestRandomAnisotropy.test_downsample()   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
from torchio.transforms import RandomAnisotropy
2
from ...utils import TorchioTestCase
3
4
5
class TestRandomAnisotropy(TorchioTestCase):
6
    """Tests for `RandomAnisotropy`."""
7
8
    def test_downsample(self):
9
        transform = RandomAnisotropy(
10
            axes=1,
11
            downsampling=(2., 2.)
12
        )
13
        transformed = transform(self.sample_subject)
14
        self.assertEqual(self.sample_subject.spacing[1], transformed.spacing[1])
15
16
    def test_out_of_range_axis(self):
17
        with self.assertRaises(ValueError):
18
            RandomAnisotropy(axes=3)
19
20
    def test_out_of_range_axis_in_tuple(self):
21
        with self.assertRaises(ValueError):
22
            RandomAnisotropy(axes=(0, -1, 2))
23
24
    def test_wrong_axes_type(self):
25
        with self.assertRaises(ValueError):
26
            RandomAnisotropy(axes='wrong')
27
28
    def test_wrong_downsampling_type(self):
29
        with self.assertRaises(ValueError):
30
            RandomAnisotropy(downsampling='wrong')
31
32
    def test_below_one_downsampling(self):
33
        with self.assertRaises(ValueError):
34
            RandomAnisotropy(downsampling=0.2)
35