def test_one_of(self): transform = OneOf({ RandomAffine(): 0.2, RandomElasticDeformation(max_displacement=0.5): 0.8, }) transform(self.sample)
def test_negative_probabilities(self): with self.assertRaises(ValueError): OneOf({RandomAffine(): -1, RandomElasticDeformation(): 1})
def test_zero_probabilities(self): with self.assertRaises(ValueError): OneOf({RandomAffine(): 0, RandomElasticDeformation(): 0})
def test_num_control_points(self): RandomElasticDeformation(num_control_points=5) RandomElasticDeformation(num_control_points=(5, 6, 7))
def test_max_displacement(self): RandomElasticDeformation(max_displacement=5) RandomElasticDeformation(max_displacement=(5, 6, 7))
def test_wrong_locked_borders(self): with self.assertRaises(ValueError): RandomElasticDeformation(locked_borders=-1)
def test_coarse_grid_removed(self): with self.assertRaises(ValueError): RandomElasticDeformation( num_control_points=(4, 5, 6), locked_borders=2, )
def test_max_displacement_no_num(self): with self.assertRaises(ValueError): RandomElasticDeformation(max_displacement=None)
def test_max_displacement_negative(self): with self.assertRaises(ValueError): RandomElasticDeformation(max_displacement=-1)
def test_num_control_points_small(self): with self.assertRaises(ValueError): RandomElasticDeformation(num_control_points=3)
def test_inputs_interpolation_string(self): with self.assertRaises(TypeError): RandomElasticDeformation(image_interpolation='linear')
def test_inputs_pta_lt_zero(self): with self.assertRaises(ValueError): RandomElasticDeformation(p=-1)
def test_inputs_pta_gt_one(self): with self.assertRaises(ValueError): RandomElasticDeformation(p=1.5)
def test_inputs_interpolation(self): with self.assertWarns(FutureWarning): RandomElasticDeformation(image_interpolation=Interpolation.LINEAR)