Coverage for tests/test_schema.py: 47%

32 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-03 11:30 +0000

1# 

2# LSST Data Management System 

3# 

4# Copyright 2018 AURA/LSST. 

5# 

6# This product includes software developed by the 

7# LSST Project (http://www.lsst.org/). 

8# 

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

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

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

12# (at your option) any later version. 

13# 

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

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

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

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the LSST License Statement and 

20# the GNU General Public License along with this program. If not, 

21# see <https://www.lsstcorp.org/LegalNotices/>. 

22# 

23import os 

24import unittest 

25 

26import lsst.utils.tests 

27import lsst.afw.image as afwImage 

28import lsst.afw.table as afwTable 

29from lsst.meas.algorithms.detection import SourceDetectionTask 

30from lsst.meas.deblender import SourceDeblendTask 

31 

32DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data") 

33 

34 

35class SchemaTestCase(lsst.utils.tests.TestCase): 

36 

37 def setUp(self): 

38 self.calexp = afwImage.ExposureF(os.path.join(DATA_DIR, "ticket1738.fits")) 

39 

40 def tearDown(self): 

41 del self.calexp 

42 

43 def testMismatchedSchema(self): 

44 schema = afwTable.SourceTable.makeMinimalSchema() 

45 

46 # Create the detection task and process the data 

47 config = SourceDetectionTask.ConfigClass() 

48 # Don't trust the variance plane for this data. 

49 config.thresholdType = "stdev" 

50 detectionTask = SourceDetectionTask(schema=schema, config=config) 

51 table = afwTable.SourceTable.make(schema) 

52 result = detectionTask.run(table, self.calexp) 

53 self.assertEqual(schema, result.sources.getSchema()) 

54 

55 # SourceDeblendTask modifies the schema in-place at construction 

56 # and add extra keys to it 

57 deblendTask = SourceDeblendTask(schema) 

58 self.assertNotEqual(schema, result.sources.getSchema()) 

59 

60 # As the deblendTask has a different schema than the original schema 

61 # of the detectionTask, the assert should fail and stop running 

62 with self.assertRaises(AssertionError): 

63 deblendTask.run(self.calexp, result.sources) 

64 

65 

66class TestMemory(lsst.utils.tests.MemoryTestCase): 

67 pass 

68 

69 

70def setup_module(module): 

71 lsst.utils.tests.init() 

72 

73 

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

75 lsst.utils.tests.init() 

76 unittest.main()