Skip to content
Snippets Groups Projects
Commit 679a575e authored by Jan Caron's avatar Jan Caron
Browse files

Added tests for high-padding-FDFC (padding=10).

parent 8ea719a5
No related branches found
No related tags found
No related merge requests found
......@@ -97,7 +97,7 @@ class TestCasePhaseMapperFDFCpad1(unittest.TestCase):
self.mapper = None
def test_PhaseMapperFDFC_call(self):
phase_ref = PhaseMap.load_from_hdf5(os.path.join(self.path, 'phase_map_fc_pad.hdf5'))
phase_ref = PhaseMap.load_from_hdf5(os.path.join(self.path, 'phase_map_fc_pad1.hdf5'))
phase_map = self.mapper(self.mag_proj)
assert_allclose(phase_map.phase, phase_ref.phase, atol=1E-7,
err_msg='Unexpected behavior in __call__()!')
......@@ -111,7 +111,41 @@ class TestCasePhaseMapperFDFCpad1(unittest.TestCase):
err_msg='Inconsistency between __call__() and jac_dot()!')
n = self.mapper.n
jac = np.array([self.mapper.jac_dot(np.eye(n)[:, i]) for i in range(n)]).T
jac_ref = np.load(os.path.join(self.path, 'jac_fc_pad.npy'))
jac_ref = np.load(os.path.join(self.path, 'jac_fc_pad1.npy'))
assert_allclose(jac, jac_ref, atol=1E-7,
err_msg='Unexpected behaviour in the the jacobi matrix!')
def test_PhaseMapperFDFC_jac_T_dot(self):
self.assertRaises(NotImplementedError, self.mapper.jac_T_dot, None)
class TestCasePhaseMapperFDFCpad10(unittest.TestCase):
def setUp(self):
self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_phasemapper')
self.mag_proj = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_proj.hdf5'))
self.mapper = PhaseMapperFDFC(self.mag_proj.a, self.mag_proj.dim[1:], padding=200)
def tearDown(self):
self.path = None
self.mag_proj = None
self.mapper = None
def test_PhaseMapperFDFC_call(self):
phase_ref = PhaseMap.load_from_hdf5(os.path.join(self.path, 'phase_map_fc_pad10.hdf5'))
phase_map = self.mapper(self.mag_proj)
assert_allclose(phase_map.phase, phase_ref.phase, atol=1E-7,
err_msg='Unexpected behavior in __call__()!')
assert_allclose(phase_map.a, phase_ref.a, err_msg='Unexpected behavior in __call__()!')
def test_PhaseMapperFDFC_jac_dot(self):
phase = self.mapper(self.mag_proj).phase
mag_proj_vec = self.mag_proj.field[:2, ...].flatten()
phase_jac = self.mapper.jac_dot(mag_proj_vec).reshape(self.mapper.dim_uv)
assert_allclose(phase, phase_jac, atol=1E-7,
err_msg='Inconsistency between __call__() and jac_dot()!')
n = self.mapper.n
jac = np.array([self.mapper.jac_dot(np.eye(n)[:, i]) for i in range(n)]).T
jac_ref = np.load(os.path.join(self.path, 'jac_fc_pad10.npy'))
assert_allclose(jac, jac_ref, atol=1E-7,
err_msg='Unexpected behaviour in the the jacobi matrix!')
......
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment