Passed
Pull Request — master (#246)
by Fernando
01:04
created

tests.data.sampler.test_patch_sampler   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A TestPatchSampler.test_bad_patch_size() 0 7 4
A TestPatchSampler.test_extract_patch() 0 2 1
1
import torch
2
import torchio
3
import numpy as np
4
from torchio.data import PatchSampler
5
from ...utils import TorchioTestCase
6
7
8
class TestPatchSampler(TorchioTestCase):
9
    """Tests for `PatchSampler` class."""
10
    def test_bad_patch_size(self):
11
        with self.assertRaises(ValueError):
12
            PatchSampler(0)
13
        with self.assertRaises(ValueError):
14
            PatchSampler(-1)
15
        with self.assertRaises(ValueError):
16
            PatchSampler(1.5)
17
18
    def test_extract_patch(self):
19
        PatchSampler(1).extract_patch(self.sample, (3, 4, 5))
20