From 277a7320e6ff5281221131c918d96555c211d8d2 Mon Sep 17 00:00:00 2001 From: Alexandre D'Astous Date: Wed, 11 Nov 2020 23:47:23 -0500 Subject: [PATCH] Add tests for singleton 2nd dim, 3rd dim, 2nd and 3rd dim --- test/test_prelude.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/test_prelude.py b/test/test_prelude.py index 9b5d277a..f22cd575 100644 --- a/test/test_prelude.py +++ b/test/test_prelude.py @@ -168,3 +168,42 @@ def test_threshold(self): """ unwrapped_phase_e1 = prelude(self.phase_e1, self.mag_e1, self.affine_phase_e1, threshold=200) assert(unwrapped_phase_e1.shape == self.phase_e1.shape) + + def test_3rd_dim_singleton(self): + """ + Call prelude on data with a singleton on the z dimension + """ + + # Prepare singleton + phase_singleton = np.expand_dims(self.phase_e1[..., 0], -1) + mag_singleton = np.expand_dims(self.mag_e1[..., 0], -1) + + unwrapped_phase_singleton = prelude(phase_singleton, mag_singleton, self.affine_phase_e1) + + assert unwrapped_phase_singleton.ndim == 3 + + def test_2nd_dim_singleton(self): + """ + Call prelude on data with a singleton on the 2nd dimension + """ + + # Prepare singleton + phase_singleton = np.expand_dims(self.phase_e1[:, 0, 0], -1) + mag_singleton = np.expand_dims(self.mag_e1[:, 0, 0], -1) + + unwrapped_phase_singleton = prelude(phase_singleton, mag_singleton, self.affine_phase_e1) + + assert unwrapped_phase_singleton.ndim == 2 + + def test_2nd_and_3rd_dim_singleton(self): + """ + Call prelude on data with a singleton on the 2nd and 3rd dimension + """ + + # Prepare singleton + phase_singleton = np.expand_dims(np.expand_dims(self.phase_e1[:, 0, 0], -1), -1) + mag_singleton = np.expand_dims(np.expand_dims(self.mag_e1[:, 0, 0], -1), -1) + + unwrapped_phase_singleton = prelude(phase_singleton, mag_singleton, self.affine_phase_e1) + + assert unwrapped_phase_singleton.ndim == 3