Coverage for tests/test_LonLat.py: 34%
27 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-03-31 09:39 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-03-31 09:39 +0000
1#
2# LSST Data Management System
3# See COPYRIGHT file at the top of the source tree.
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 <https://www.lsstcorp.org/LegalNotices/>.
21#
23import pickle
24import unittest
26from lsst.sphgeom import Angle, LonLat, NormalizedAngle, UnitVector3d
29class LonLatTestCase(unittest.TestCase):
30 def testConstruction(self):
31 p = LonLat.fromDegrees(45, 45)
32 self.assertEqual(p, LonLat(NormalizedAngle.fromDegrees(45), Angle.fromDegrees(45)))
33 u = UnitVector3d(p)
34 q = LonLat(u)
35 self.assertAlmostEqual(p.getLon().asRadians(), q.getLon().asRadians(), places=13)
36 self.assertAlmostEqual(p.getLat().asRadians(), q.getLat().asRadians(), places=13)
37 self.assertAlmostEqual(p.getLon().asRadians(), LonLat.latitudeOf(u).asRadians(), places=13)
38 self.assertAlmostEqual(p.getLon().asRadians(), LonLat.longitudeOf(u).asRadians(), places=13)
40 def testComparisonOperators(self):
41 self.assertEqual(LonLat.fromDegrees(45, 45), LonLat.fromDegrees(45, 45))
42 self.assertNotEqual(LonLat.fromDegrees(0, 0), LonLat.fromDegrees(45, 45))
44 def testString(self):
45 p = LonLat.fromRadians(1, 1)
46 self.assertEqual(str(p), "[1.0, 1.0]")
47 self.assertEqual(repr(p), "LonLat.fromRadians(1.0, 1.0)")
48 self.assertEqual(p, eval(repr(p), dict(LonLat=LonLat)))
50 def testPickle(self):
51 p = LonLat.fromRadians(2, 1)
52 q = pickle.loads(pickle.dumps(p))
53 self.assertEqual(p, q)
56if __name__ == "__main__": 56 ↛ 57line 56 didn't jump to line 57, because the condition on line 56 was never true
57 unittest.main()