From 22fc4cb9aefe565c5b8a4678f6f83108e2f9afa1 Mon Sep 17 00:00:00 2001 From: "borondics.accounts@gmail.com" Date: Wed, 20 Nov 2024 15:49:18 +0100 Subject: [PATCH 1/3] Added tests for map coordinates. --- orangecontrib/spectroscopy/tests/test_readers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/orangecontrib/spectroscopy/tests/test_readers.py b/orangecontrib/spectroscopy/tests/test_readers.py index 8b39407b9..1cf83af09 100644 --- a/orangecontrib/spectroscopy/tests/test_readers.py +++ b/orangecontrib/spectroscopy/tests/test_readers.py @@ -238,6 +238,12 @@ def test_map_reader(self): self.assertEqual(min(getx(d)), 750.0) self.assertEqual(max(getx(d)), 4000.0) + def test_map_reader_coordinates(self): + d = Orange.data.Table("perkinelmer/4x4_pixel_PE_image.fsm") + self.assertEqual(d.metas[1][0], 17530.000000993412) + self.assertEqual(d.metas[1][1], 2749.0000029802322) + self.assertEqual(d.metas[2][0], 17579.999999006588) + self.assertEqual(d.metas[2][1], 2749.0000029802322) class TestAgilentReader(unittest.TestCase): From 83013f11cbefd3b25409a760030da9c6e141590a Mon Sep 17 00:00:00 2001 From: "borondics.accounts@gmail.com" Date: Thu, 21 Nov 2024 17:06:44 +0100 Subject: [PATCH 2/3] Testing all map coordinates. --- .../spectroscopy/tests/test_readers.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/orangecontrib/spectroscopy/tests/test_readers.py b/orangecontrib/spectroscopy/tests/test_readers.py index 1cf83af09..040893e4b 100644 --- a/orangecontrib/spectroscopy/tests/test_readers.py +++ b/orangecontrib/spectroscopy/tests/test_readers.py @@ -240,10 +240,24 @@ def test_map_reader(self): def test_map_reader_coordinates(self): d = Orange.data.Table("perkinelmer/4x4_pixel_PE_image.fsm") - self.assertEqual(d.metas[1][0], 17530.000000993412) - self.assertEqual(d.metas[1][1], 2749.0000029802322) - self.assertEqual(d.metas[2][0], 17579.999999006588) - self.assertEqual(d.metas[2][1], 2749.0000029802322) + map_x = np.array([17480, 17530, 17579, + 17629, 17480, 17530, + 17579, 17629, 17480, + 17530, 17579, 17629, + 17480, 17530, 17579, + 17629]) + + map_y = np.array([2749, 2749, 2749, + 2749, 2799, 2799, + 2799, 2799, 2848, + 2848, 2848, 2848, + 2898, 2898, 2898, + 2898,]) + + for k, l, m, n in zip(d.metas[:, 0], map_x, d.metas[:, 1], map_y): + self.assertAlmostEqual(int(k), l, places=int) + self.assertAlmostEqual(int(m), n, places=int) + class TestAgilentReader(unittest.TestCase): From 9f96cfa46558a24440da780e54824cba98b987b4 Mon Sep 17 00:00:00 2001 From: Marko Toplak Date: Wed, 27 Nov 2024 11:45:22 +0100 Subject: [PATCH 3/3] fix tests --- .../spectroscopy/tests/test_readers.py | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/orangecontrib/spectroscopy/tests/test_readers.py b/orangecontrib/spectroscopy/tests/test_readers.py index 040893e4b..3e926ff1a 100644 --- a/orangecontrib/spectroscopy/tests/test_readers.py +++ b/orangecontrib/spectroscopy/tests/test_readers.py @@ -238,25 +238,10 @@ def test_map_reader(self): self.assertEqual(min(getx(d)), 750.0) self.assertEqual(max(getx(d)), 4000.0) - def test_map_reader_coordinates(self): - d = Orange.data.Table("perkinelmer/4x4_pixel_PE_image.fsm") - map_x = np.array([17480, 17530, 17579, - 17629, 17480, 17530, - 17579, 17629, 17480, - 17530, 17579, 17629, - 17480, 17530, 17579, - 17629]) - - map_y = np.array([2749, 2749, 2749, - 2749, 2799, 2799, - 2799, 2799, 2848, - 2848, 2848, 2848, - 2898, 2898, 2898, - 2898,]) - - for k, l, m, n in zip(d.metas[:, 0], map_x, d.metas[:, 1], map_y): - self.assertAlmostEqual(int(k), l, places=int) - self.assertAlmostEqual(int(m), n, places=int) + map_x = np.tile([17480, 17530, 17580, 17630], 4) + map_y = np.repeat([2749, 2799, 2849, 2899], 4) + np.testing.assert_almost_equal(d.metas[:, 0], map_x, decimal=5) + np.testing.assert_almost_equal(d.metas[:, 1], map_y, decimal=5) class TestAgilentReader(unittest.TestCase):