| Total Complexity | 8 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | #!/usr/bin/env python |
||
| 2 | |||
| 3 | """Tests for Image.""" |
||
| 4 | |||
| 5 | import torch |
||
|
|
|||
| 6 | from torchio import INTENSITY, Image |
||
| 7 | from ..utils import TorchioTestCase |
||
| 8 | from torchio import RandomFlip, RandomAffine |
||
| 9 | |||
| 10 | |||
| 11 | class TestImage(TorchioTestCase): |
||
| 12 | """Tests for `Image`.""" |
||
| 13 | |||
| 14 | def test_image_not_found(self): |
||
| 15 | with self.assertRaises(FileNotFoundError): |
||
| 16 | Image('nopath', INTENSITY) |
||
| 17 | |||
| 18 | def test_wrong_path_type(self): |
||
| 19 | with self.assertRaises(TypeError): |
||
| 20 | Image(5, INTENSITY) |
||
| 21 | |||
| 22 | def test_incompatible_arguments(self): |
||
| 23 | with self.assertRaises(ValueError): |
||
| 24 | Image(5, INTENSITY, affine=1) |
||
| 25 | |||
| 26 | def test_tensor_flip(self): |
||
| 27 | sample_input = torch.ones((4, 30, 30, 30)) |
||
| 28 | RandomFlip()(sample_input) |
||
| 29 | |||
| 30 | def test_tensor_affine(self): |
||
| 31 | sample_input = torch.ones((4, 10, 10, 10)) |
||
| 32 | RandomAffine()(sample_input) |
||