Passed
Push — main ( c95fa1...287682 )
by Fernando
01:32
created

TestTo.test_to()   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 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