Coverage for tests/test_Q3cPixelization.py : 21%

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#
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, Circle, Q3cPixelization, RangeSet, UnitVector3d
29class Q3cPixelizationTestCase(unittest.TestCase):
31 def test_construction(self):
32 with self.assertRaises(ValueError):
33 Q3cPixelization(-1)
34 with self.assertRaises(ValueError):
35 Q3cPixelization(Q3cPixelization.MAX_LEVEL + 1)
36 q1 = Q3cPixelization(0)
37 self.assertEqual(q1.getLevel(), 0)
38 q2 = Q3cPixelization(1)
39 q3 = Q3cPixelization(q2)
40 self.assertNotEqual(q1, q2)
41 self.assertEqual(q2, q3)
43 def test_indexing(self):
44 pixelization = Q3cPixelization(1)
45 self.assertEqual(pixelization.index(UnitVector3d(0.5, -0.5, 1.0)), 0)
47 def test_envelope_and_interior(self):
48 pixelization = Q3cPixelization(1)
49 c = Circle(UnitVector3d(1.0, -0.5, -0.5), Angle.fromDegrees(0.1))
50 rs = pixelization.envelope(c)
51 self.assertTrue(rs == RangeSet(4))
52 rs = pixelization.envelope(c, 1)
53 self.assertTrue(rs == RangeSet(4))
54 self.assertTrue(rs.isWithin(pixelization.universe()))
55 rs = pixelization.interior(c)
56 self.assertTrue(rs.empty())
58 def test_index_to_string(self):
59 strings = ['+X', '+Y', '+Z', '-X', '-Y', '-Z']
60 for i in range(6):
61 s = strings[i]
62 components = [0.0]*3
63 components[i % 3] = 1.0 if i < 3 else -1.0
64 v = UnitVector3d(*components)
65 f = Q3cPixelization(0).index(v)
66 self.assertEqual(Q3cPixelization(0).toString(f), s)
67 for j in range(4):
68 self.assertEqual(Q3cPixelization(1).toString(f*4 + j),
69 s + str(j))
71 def test_string(self):
72 p = Q3cPixelization(3)
73 self.assertEqual(str(p), 'Q3cPixelization(3)')
74 self.assertEqual(str(p), repr(p))
75 self.assertEqual(
76 p, eval(repr(p), dict(Q3cPixelization=Q3cPixelization)))
78 def test_pickle(self):
79 a = Q3cPixelization(20)
80 b = pickle.loads(pickle.dumps(a))
81 self.assertEqual(a, b)
84if __name__ == '__main__': 84 ↛ 85line 84 didn't jump to line 85, because the condition on line 84 was never true
85 unittest.main()