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

TestRandomBlur.test_with_blurring()   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 RandomBlur
2
from ...utils import TorchioTestCase
3
from numpy.testing import assert_array_equal
4
5
6
class TestRandomBlur(TorchioTestCase):
7
    """Tests for `RandomBlur`."""
8
    def test_no_blurring(self):
9
        transform = RandomBlur(std=0)
10
        transformed = transform(self.sample)
11
        assert_array_equal(self.sample.t1.data, transformed.t1.data)
12
13
    def test_with_blurring(self):
14
        transform = RandomBlur(std=(1, 3))
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_negative_std(self):
20
        with self.assertRaises(ValueError):
21
            RandomBlur(std=-2)
22
23
    def test_std_range_with_negative_min(self):
24
        with self.assertRaises(ValueError):
25
            RandomBlur(std=(-0.5, 4))
26
27
    def test_wrong_std_type(self):
28
        with self.assertRaises(ValueError):
29
            RandomBlur(std='wrong')
30