for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
import torchio
from torchio.transforms import OneOf, RandomAffine, RandomElasticDeformation
from ...utils import TorchioTestCase
class TestOneOf(TorchioTestCase):
"""Tests for `OneOf`."""
def test_wrong_input_type(self):
with self.assertRaises(ValueError):
OneOf(1)
def test_negative_probabilities(self):
OneOf({RandomAffine(): -1, RandomElasticDeformation(): 1})
def test_zero_probabilities(self):
OneOf({RandomAffine(): 0, RandomElasticDeformation(): 0})
def test_not_transform(self):
OneOf({RandomAffine: 1, RandomElasticDeformation: 2})
def test_one_of(self):
transform = OneOf(
{RandomAffine(): 0.2, RandomElasticDeformation(): 0.8})
transform(self.sample)