Passed
Push — master ( 0a9301...f0d368 )
by Fernando
01:26
created

TestRandomFlip.test_wrong_axes()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
from torchio import RandomFlip
2
from numpy.testing import assert_array_equal
3
from ...utils import TorchioTestCase
4
5
6
class TestRandomFlip(TorchioTestCase):
7
    """Tests for `RandomFlip`."""
8
    def test_2d(self):
9
        sample = self.make_2d(self.sample)
10
        transform = RandomFlip(axes=(1, 2), flip_probability=1)
11
        transformed = transform(sample)
12
        assert_array_equal(
13
            sample.t1.data.numpy()[:, :, ::-1, ::-1],
14
            transformed.t1.data.numpy())
15
16
    def test_out_of_range_axis(self):
17
        with self.assertRaises(ValueError):
18
            RandomFlip(axes=3)
19
20
    def test_out_of_range_axis_in_tuple(self):
21
        with self.assertRaises(ValueError):
22
            RandomFlip(axes=(0, -1, 2))
23
24
    def test_wrong_axes_type(self):
25
        with self.assertRaises(ValueError):
26
            RandomFlip(axes=None)
27
28
    def test_wrong_flip_probability_type(self):
29
        with self.assertRaises(ValueError):
30
            RandomFlip(flip_probability='wrong')
31