| Total Complexity | 1 |
| Total Lines | 18 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import torch |
||
| 2 | |||
| 3 | import torchio as tio |
||
| 4 | |||
| 5 | from ...utils import TorchioTestCase |
||
| 6 | |||
| 7 | |||
| 8 | class TestTo(TorchioTestCase): |
||
| 9 | """Tests for :class:`tio.To` class.""" |
||
| 10 | |||
| 11 | def test_to(self): |
||
| 12 | transform = tio.To(torch.int) |
||
| 13 | tensor = 10 * torch.rand(2, 3, 4, 5) |
||
| 14 | image = tio.ScalarImage(tensor=tensor) |
||
| 15 | transformed = transform(image) |
||
| 16 | assert image.data.dtype == torch.float32 |
||
| 17 | assert transformed.data.dtype == torch.int |
||
| 18 |