Coverage for tests/test_LonLat.py: 39%
27 statements
« prev ^ index » next coverage.py v6.4, created at 2022-05-24 02:22 -0700
« prev ^ index » next coverage.py v6.4, created at 2022-05-24 02:22 -0700
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):
31 def testConstruction(self):
32 p = LonLat.fromDegrees(45, 45)
33 self.assertEqual(p, LonLat(NormalizedAngle.fromDegrees(45),
34 Angle.fromDegrees(45)))
35 u = UnitVector3d(p)
36 q = LonLat(u)
37 self.assertAlmostEqual(
38 p.getLon().asRadians(), q.getLon().asRadians(), places=13)
39 self.assertAlmostEqual(
40 p.getLat().asRadians(), q.getLat().asRadians(), places=13)
41 self.assertAlmostEqual(p.getLon().asRadians(),
42 LonLat.latitudeOf(u).asRadians(),
43 places=13)
44 self.assertAlmostEqual(p.getLon().asRadians(),
45 LonLat.longitudeOf(u).asRadians(),
46 places=13)
48 def testComparisonOperators(self):
49 self.assertEqual(LonLat.fromDegrees(45, 45),
50 LonLat.fromDegrees(45, 45))
51 self.assertNotEqual(LonLat.fromDegrees(0, 0),
52 LonLat.fromDegrees(45, 45))
54 def testString(self):
55 p = LonLat.fromRadians(1, 1)
56 self.assertEqual(str(p), '[1.0, 1.0]')
57 self.assertEqual(repr(p), 'LonLat.fromRadians(1.0, 1.0)')
58 self.assertEqual(p, eval(repr(p), dict(LonLat=LonLat)))
60 def testPickle(self):
61 p = LonLat.fromRadians(2, 1)
62 q = pickle.loads(pickle.dumps(p))
63 self.assertEqual(p, q)
66if __name__ == '__main__': 66 ↛ 67line 66 didn't jump to line 67, because the condition on line 66 was never true
67 unittest.main()