Coverage for tests / test_diaSourceMetrics.py: 45%

18 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-15 00:23 +0000

1# 

2# Developed for the LSST Data Management System. 

3# This product includes software developed by the LSST Project 

4# (https://www.lsst.org). 

5# See the COPYRIGHT file at the top-level directory of this distribution 

6# for details of code ownership. 

7# 

8# This program is free software: you can redistribute it and/or modify 

9# it under the terms of the GNU General Public License as published by 

10# the Free Software Foundation, either version 3 of the License, or 

11# (at your option) any later version. 

12# 

13# This program is distributed in the hope that it will be useful, 

14# but WITHOUT ANY WARRANTY; without even the implied warranty of 

15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

16# GNU General Public License for more details. 

17# 

18# You should have received a copy of the GNU General Public License 

19# along with this program. If not, see <https://www.gnu.org/licenses/>. 

20 

21import unittest 

22 

23import lsst.utils.tests 

24from astropy.table import Table 

25from lsst.analysis.tools.atools import diaSourceMetrics as diaAtool 

26 

27 

28class DiaSourceTest(lsst.utils.tests.TestCase): 

29 """Test to see if DiaSources are counted as expected 

30 and a plot is generated without falling over.""" 

31 

32 def setUp(self): 

33 testFile = "tests/data/assocDiaSrc_test.ecsv" 

34 self.data = Table.read(testFile) 

35 

36 def test_metrics(self): 

37 """Test that metrics have the expected values from the test data.""" 

38 NumDiaSources = diaAtool.NumGoodDiaSourcesMetrics() 

39 NumDiaSources.finalize() 

40 DiaSourceCount = NumDiaSources(self.data) 

41 self.assertEqual(DiaSourceCount["numAllDiaSources"].quantity.value, 2994) 

42 self.assertEqual(DiaSourceCount["numGoodDiaSources"].quantity.value, 2938) 

43 self.assertEqual(DiaSourceCount["ratioGoodToAllDiaSources"].quantity.value, 2938 / 2994) 

44 

45 

46if __name__ == "__main__": 46 ↛ 47line 46 didn't jump to line 47 because the condition on line 46 was never true

47 lsst.utils.tests.init() 

48 unittest.main()