diff --git a/pyramid/tests/test_phasemapper.py b/pyramid/tests/test_phasemapper.py index d16745877ea2e785b05333d281c4d68b38775844..746b107e111bda6e64b57e4da294866c8e040bc3 100644 --- a/pyramid/tests/test_phasemapper.py +++ b/pyramid/tests/test_phasemapper.py @@ -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!') diff --git a/pyramid/tests/test_phasemapper/jac_fc_pad.npy b/pyramid/tests/test_phasemapper/jac_fc_pad1.npy similarity index 100% rename from pyramid/tests/test_phasemapper/jac_fc_pad.npy rename to pyramid/tests/test_phasemapper/jac_fc_pad1.npy diff --git a/pyramid/tests/test_phasemapper/jac_fc_pad10.npy b/pyramid/tests/test_phasemapper/jac_fc_pad10.npy new file mode 100644 index 0000000000000000000000000000000000000000..963a5dc1853a96000b6304e47498cb51f2959e2c Binary files /dev/null and b/pyramid/tests/test_phasemapper/jac_fc_pad10.npy differ diff --git a/pyramid/tests/test_phasemapper/phase_map_fc_pad.hdf5 b/pyramid/tests/test_phasemapper/phase_map_fc_pad1.hdf5 similarity index 100% rename from pyramid/tests/test_phasemapper/phase_map_fc_pad.hdf5 rename to pyramid/tests/test_phasemapper/phase_map_fc_pad1.hdf5 diff --git a/pyramid/tests/test_phasemapper/phase_map_fc_pad10.hdf5 b/pyramid/tests/test_phasemapper/phase_map_fc_pad10.hdf5 new file mode 100644 index 0000000000000000000000000000000000000000..df8258665764451df583d014660e9e747e5c65d6 Binary files /dev/null and b/pyramid/tests/test_phasemapper/phase_map_fc_pad10.hdf5 differ