Passed
Push — master ( c291a8...879ee9 )
by Fernando
59s
created

tests.transforms.augmentation.test_random_bias_field   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 9

5 Methods

Rating   Name   Duplication   Size   Complexity  
A TestRandomBiasField.test_with_bias() 0 5 2
A TestRandomBiasField.test_wrong_order_type() 0 3 2
A TestRandomBiasField.test_no_bias() 0 4 1
A TestRandomBiasField.test_wrong_coefficient_type() 0 3 2
A TestRandomBiasField.test_negative_order() 0 3 2
1
from torchio import RandomBiasField
2
from ...utils import TorchioTestCase
3
from numpy.testing import assert_array_equal
4
5
6
class TestRandomBiasField(TorchioTestCase):
7
    """Tests for `RandomBiasField`."""
8
    def test_no_bias(self):
9
        transform = RandomBiasField(coefficients=0.)
10
        transformed = transform(self.sample)
11
        assert_array_equal(self.sample.t1.data, transformed.t1.data)
12
13
    def test_with_bias(self):
14
        transform = RandomBiasField(coefficients=0.1)
15
        transformed = transform(self.sample)
16
        with self.assertRaises(AssertionError):
17
            assert_array_equal(self.sample.t1.data, transformed.t1.data)
18
19
    def test_wrong_coefficient_type(self):
20
        with self.assertRaises(ValueError):
21
            RandomBiasField(coefficients='wrong')
22
23
    def test_negative_order(self):
24
        with self.assertRaises(ValueError):
25
            RandomBiasField(order=-1)
26
27
    def test_wrong_order_type(self):
28
        with self.assertRaises(TypeError):
29
            RandomBiasField(order='wrong')
30