From 3109e1585c03d4d6ba59740a68916f0d2e4ec330 Mon Sep 17 00:00:00 2001 From: Matthew Tino Date: Thu, 29 Aug 2024 22:25:02 -0400 Subject: [PATCH] FIX: Updated unit tests after mods to self_assembly/misc/read_image --- shapelets/tests/test_self_assembly_basic.py | 16 ++++++++-------- shapelets/tests/test_self_assembly_methods.py | 10 +++++++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/shapelets/tests/test_self_assembly_basic.py b/shapelets/tests/test_self_assembly_basic.py index 559d893..8633982 100644 --- a/shapelets/tests/test_self_assembly_basic.py +++ b/shapelets/tests/test_self_assembly_basic.py @@ -49,12 +49,12 @@ def test_a_read_image(self) -> None: self.assertTrue(isinstance(self.lamSIM, np.ndarray)) self.assertEqual(self.lamSIM.min(), -1) self.assertEqual(self.lamSIM.max(), 1) - self.assertEqual(self.lamSIM.shape, (296, 296)) + self.assertEqual(self.lamSIM.shape, (883, 883)) self.assertTrue(isinstance(self.hexSIM, np.ndarray)) self.assertEqual(self.hexSIM.min(), -1) self.assertEqual(self.hexSIM.max(), 1) - self.assertEqual(self.hexSIM.shape, (507, 507)) + self.assertEqual(self.hexSIM.shape, (876, 876)) # Test get_wavelength def test_scaling(self) -> None: @@ -63,27 +63,27 @@ def test_scaling(self) -> None: lamSIM_wvl = get_wavelength(image = self.lamSIM, verbose = False) self.assertTrue(isinstance(lamSIM_wvl, numbers.Real)) - self.assertAlmostEqual(lamSIM_wvl, 10.231, places = 3) + self.assertAlmostEqual(lamSIM_wvl, 30.42, places = 2) lamSIM_beta_n0 = lambda_to_beta_n0(3, lamSIM_wvl) self.assertTrue(isinstance(lamSIM_beta_n0, numbers.Real)) - self.assertAlmostEqual(lamSIM_beta_n0, 3.41, places = 2) + self.assertAlmostEqual(lamSIM_beta_n0, 10.14, places = 2) lamSIM_beta_n1 = lambda_to_beta_n1(3, lamSIM_wvl) self.assertTrue(isinstance(lamSIM_beta_n1, numbers.Real)) - self.assertAlmostEqual(lamSIM_beta_n1, 7.3, places = 5) + self.assertAlmostEqual(lamSIM_beta_n1, 22.9, places = 5) hexSIM_wvl = get_wavelength(image = self.hexSIM, verbose = False) self.assertTrue(isinstance(hexSIM_wvl, numbers.Real)) - self.assertAlmostEqual(hexSIM_wvl, 16.882, places = 3) + self.assertAlmostEqual(hexSIM_wvl, 29.24, places = 2) hexSIM_beta_n0 = lambda_to_beta_n0(6, hexSIM_wvl) self.assertTrue(isinstance(hexSIM_beta_n0, numbers.Real)) - self.assertAlmostEqual(hexSIM_beta_n0, 6.89, places = 2) + self.assertAlmostEqual(hexSIM_beta_n0, 11.94, places = 2) hexSIM_beta_n1 = lambda_to_beta_n1(6, hexSIM_wvl) self.assertTrue(isinstance(hexSIM_beta_n1, numbers.Real)) - self.assertAlmostEqual(hexSIM_beta_n1, 9.1, places = 5) + self.assertAlmostEqual(hexSIM_beta_n1, 16.0, places = 1) if __name__ == "__main__": unittest.main() diff --git a/shapelets/tests/test_self_assembly_methods.py b/shapelets/tests/test_self_assembly_methods.py index 46743b4..00de5f4 100644 --- a/shapelets/tests/test_self_assembly_methods.py +++ b/shapelets/tests/test_self_assembly_methods.py @@ -41,10 +41,13 @@ def setUpClass(cls) -> None: cls.dir = __file__.replace(os.path.basename(__file__), 'images/') # Ensure core functions have appropriate outputs before proceeding. - # Note that read_image and get_wavelength are not tested here, so inline asserts - # are used to ensure correct output. + # NOTE: read_image & get_wavelength are not tested here, so inline asserts are used to ensure correct output. + cls.image = read_image(image_name="hexSIM1.png", image_path=cls.dir, verbose=False) + cls.image_nonresized = read_image(image_name="hexSIM1.png", image_path=cls.dir, do_rescale=False, verbose=False) + assert isinstance(cls.image, np.ndarray) + assert isinstance(cls.image_nonresized, np.ndarray) cls.omega, cls.phi = convresponse_n0(cls.image, shapelet_order='default', verbose=False) @@ -105,7 +108,8 @@ def test_orientation(self) -> None: with self.assertRaises(TypeError): orientation(self.image, pattern_order=1.) - mask, dilate, orient_result, _ = orientation(self.image, pattern_order='hexagonal', verbose=False) + # use non resized image since orientation method has long compute times + mask, dilate, orient_result, _ = orientation(self.image_nonresized, pattern_order='hexagonal', verbose=False) self.assertTrue(isinstance(mask, np.ndarray)) self.assertTrue(isinstance(dilate, np.ndarray))