def test_wrong_method_name(self): with self.assertRaises(ValueError): reg.get_shift( reference_array=self.reference_array, shifted_array=self.shifted_array, shift_method="wrong", )
def test_precision_None(self): with self.assertRaises(ValueError): reg.get_shift( reference_array=self.reference_array, shifted_array=self.shifted_array, precision=None, )
def test_precision_float(self): with self.assertRaises(TypeError): reg.get_shift( reference_array=self.reference_array, shifted_array=self.shifted_array, precision=2.3, )
def test_method_support_none(self): with self.assertRaises(ValueError): reg.get_shift( reference_array=self.reference_array, shifted_array=self.shifted_array, shift_method="support", )
def setUp(self): # executed before each test reference_array = np.zeros((5, 5, 5), dtype=complex) reference_array[1:4, 1:4, 1:4] = 1 + 1j shifted_array = np.zeros((5, 5, 5), dtype=complex) shifted_array[2:, 2:, 0:3] = 1 + 1j self.reference_array = reference_array self.shifted_array = shifted_array self.shifts = reg.get_shift(reference_array=self.reference_array, shifted_array=self.shifted_array)
def test_method_modulus(self): shifts = reg.get_shift( reference_array=self.reference_array, shifted_array=self.shifted_array, shift_method="modulus", ) self.assertTrue( np.allclose( np.asarray(shifts), np.array([-1.0, -1.0]), rtol=1e-09, atol=1e-09, ))
def test_precision_min_allowed(self): shifts = reg.get_shift( reference_array=self.reference_array, shifted_array=self.shifted_array, precision=1, ) self.assertTrue( np.allclose( np.asarray(shifts), np.array([-1.0, -1.0, 1.0]), rtol=1e-09, atol=1e-09, ))
def test_method_support(self): shifts = reg.get_shift( reference_array=self.reference_array, shifted_array=self.shifted_array, shift_method="support", support_threshold=0.5, ) self.assertTrue( np.allclose( np.asarray(shifts), np.array([-1.0, -1.0, 1.0]), rtol=1e-09, atol=1e-09, ))