From 3f99af3a5346838dbe4991797645bf44c2e674ee Mon Sep 17 00:00:00 2001 From: Julian Saffer Date: Wed, 18 Dec 2024 04:10:40 -0600 Subject: [PATCH] Adding tests for weighted effective area, also covering the ValueError of invalid flux argument and the TypeError of a valid flux argument that is not supported yet --- tests/test_weighter.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_weighter.py b/tests/test_weighter.py index 4433188..9f4457a 100755 --- a/tests/test_weighter.py +++ b/tests/test_weighter.py @@ -207,6 +207,23 @@ def test_effective_area(self): self.weighter1.effective_area(np.linspace(5e5, 5e6, self.N1 + 1), [0, 1]), [np.full(self.N1, self.c1.etendue / 2e4 / np.pi)], ) + self.assertAlmostEqual( + self.weighter1.effective_area([5e5, 5e6], [0, 1], flux=TIG1996())[0][0], + 149998.97822505102, + 6, + ) + self.assertAlmostEqual( + self.weighter1.effective_area([5e5, 5e6], [0, 1], np.ones(self.N1, dtype=bool), flux=TIG1996())[0][0], + 149998.97822505102, + 6, + ) + + with self.assertRaises(ValueError): + self.weighter1.effective_area([5e5, 5e6], [0, 1], flux="flux") + + with self.assertRaises(TypeError): + self.weighter1.effective_area([5e5, 5e6], [0, 1], flux=list(range(self.N1))) + def test_weighter_addition(self): weighter_sum = self.weighter1 + self.weighter1