Coverage for tests / test_diaSourceMetrics.py: 45%

18 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-30 09:27 +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 

23from astropy.table import Table 

24 

25import lsst.utils.tests 

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

27 

28 

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

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

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

32 

33 def setUp(self): 

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

35 self.data = Table.read(testFile) 

36 

37 def test_metrics(self): 

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

39 NumDiaSources = diaAtool.NumGoodDiaSourcesMetrics() 

40 NumDiaSources.finalize() 

41 DiaSourceCount = NumDiaSources(self.data) 

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

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

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

45 

46 

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

48 lsst.utils.tests.init() 

49 unittest.main()