| Total Complexity | 3 |
| Total Lines | 17 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import torch |
||
| 2 | import torchio as tio |
||
| 3 | from ...utils import TorchioTestCase |
||
| 4 | |||
| 5 | |||
| 6 | class TestOneHot(TorchioTestCase): |
||
| 7 | """Tests for `OneHot`.""" |
||
| 8 | def test_one_hot(self): |
||
| 9 | image = self.sample_subject.label |
||
| 10 | one_hot = tio.OneHot(num_classes=3)(image) |
||
| 11 | assert one_hot.num_channels == 3 |
||
| 12 | |||
| 13 | def test_multichannel(self): |
||
| 14 | label_map = tio.LabelMap(tensor=torch.rand(2, 3, 3, 3) > 1) |
||
| 15 | with self.assertRaises(RuntimeError): |
||
| 16 | tio.OneHot()(label_map) |
||
| 17 |