Passed
Push — master ( 4d15eb...9754c7 )
by Fernando
01:24
created

TestImage.test_tensor_affine()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
#!/usr/bin/env python
2
3
"""Tests for Image."""
4
5
import torch
0 ignored issues
show
introduced by
Unable to import 'torch'
Loading history...
6
from torchio import INTENSITY, Image
7
from ..utils import TorchioTestCase
8
from torchio import RandomFlip, RandomAffine
0 ignored issues
show
introduced by
first party import "from torchio import RandomFlip, RandomAffine" should be placed before "from ..utils import TorchioTestCase"
Loading history...
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):
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
27
        sample_input = torch.ones((4, 30, 30, 30))
28
        RandomFlip()(sample_input)
29
30
    def test_tensor_affine(self):
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
31
        sample_input = torch.ones((4, 10, 10, 10))
32
        RandomAffine()(sample_input)
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...