Coverage for tests/test_ellipKPM.py : 45%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of faro.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
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 GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
22"""Unit tests for the metrics measurement system: TE1.
23"""
25import unittest
26import yaml
27import os
28import logging
30from lsst.utils import getPackageDir
31from lsst.afw.table import SimpleCatalog
32from lsst.faro.measurement import TExTask
34log = logging.getLogger(__name__)
36DATADIR = os.path.join(getPackageDir('faro'), 'tests', 'data')
39class Te1Test(unittest.TestCase):
41 def load_data(self, key):
42 '''Helper to load data to process and the expected value.'''
43 cat_file, expected_file = self.file_map[key]
44 catalog = SimpleCatalog.readFits(os.path.join(DATADIR, cat_file))
45 with open(os.path.join(DATADIR, expected_file), 'r') as fh:
46 expected = yaml.load(fh, Loader=yaml.FullLoader)
47 return catalog, expected
49 @classmethod
50 def setUpClass(cls):
51 '''This gets called once so can be used to set up
52 state that is used by all test methods.'''
53 super().setUpClass()
54 cls.file_map = {('TE1', 'i'):
55 ('src_HSC_i_HSC-I_903986_0_31_HSC_runs_ci_hsc_20210407T021858Z.fits',
56 'TE1_expected_0_i.yaml')}
58 @classmethod
59 def tearDownClass(cls):
60 '''Delete any variables set in setUpClass.'''
61 del cls.file_map
62 super().tearDownClass()
64 def test_te1(self):
65 """Test calculation of TE1 on a known catalog."""
66 config = TExTask.ConfigClass()
67 # This is what makes it TE1
68 config.minSep = 0.25
69 config.maxSep = 1.0
70 task = TExTask(config=config)
71 for band in ('i'):
72 catalog, expected = self.load_data(('TE1', band))
73 result = task.run('TE1', [catalog])
74 log.debug('result: ', result)
75 log.debug('expected: ', expected)
76 self.assertEqual(result.measurement, expected)
79if __name__ == "__main__": 79 ↛ 80line 79 didn't jump to line 80, because the condition on line 79 was never true
80 unittest.main()