| Total Complexity | 9 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 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 |