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

tests.transforms.augmentation.test_random_anisotropy   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 11

6 Methods

Rating   Name   Duplication   Size   Complexity  
A TestRandomAnisotropy.test_out_of_range_axis_in_tuple() 0 3 2
A TestRandomAnisotropy.test_wrong_axes_type() 0 3 2
A TestRandomAnisotropy.test_wrong_downsampling_type() 0 3 2
A TestRandomAnisotropy.test_out_of_range_axis() 0 3 2
A TestRandomAnisotropy.test_downsample() 0 7 1
A TestRandomAnisotropy.test_below_one_downsampling() 0 3 2
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