Coverage for tests/test_header.py: 29%
28 statements
« prev ^ index » next coverage.py v7.2.5, created at 2023-05-11 03:10 -0700
« prev ^ index » next coverage.py v7.2.5, created at 2023-05-11 03:10 -0700
1#
2# LSST Data Management System
3# Copyright 2008-2013 LSST Corporation.
4#
5# This product includes software developed by the
6# LSST Project (http://www.lsst.org/).
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 LSST License Statement and
19# the GNU General Public License along with this program. If not,
20# see <http://www.lsstcorp.org/LegalNotices/>.
21#
23import unittest
25import numpy
27import lsst.afw.image as afwImage
28import lsst.utils.tests
31class HeaderTestCase(lsst.utils.tests.TestCase):
32 """Test that headers round-trip"""
34 def testHeaders(self):
35 header = {"STR": "String",
36 "INT": 12345,
37 "FLOAT": 678.9,
38 "NAN": numpy.nan,
39 "PLUSINF": numpy.inf,
40 "MINUSINF": -numpy.inf,
41 "LONG": 987654321,
42 }
44 exp = afwImage.ExposureI(0, 0)
45 metadata = exp.getMetadata()
46 for k, v in header.items():
47 metadata.add(k, v)
49 with lsst.utils.tests.getTempFilePath(".fits") as filename:
50 exp.writeFits(filename)
51 exp = afwImage.ExposureI(filename)
53 metadata = exp.getMetadata()
54 for k, v in header.items():
55 self.assertTrue(metadata.exists(k))
56 if isinstance(v, float) and numpy.isnan(v):
57 self.assertIsInstance(metadata.getScalar(k), float)
58 self.assertTrue(numpy.isnan(metadata.getScalar(k)))
59 else:
60 self.assertEqual(metadata.getScalar(k), v)
63class TestMemory(lsst.utils.tests.MemoryTestCase):
64 pass
67def setup_module(module):
68 lsst.utils.tests.init()
71if __name__ == "__main__": 71 ↛ 72line 71 didn't jump to line 72, because the condition on line 71 was never true
72 lsst.utils.tests.init()
73 unittest.main()