Coverage for tests/test_Chunker.py: 27%
42 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-14 02:23 -0800
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-14 02:23 -0800
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 Box, Chunker
29class ChunkerTestCase(unittest.TestCase):
30 def testConstruction(self):
31 chunker = Chunker(85, 12)
32 self.assertEqual(chunker.numStripes, 85)
33 self.assertEqual(chunker.numSubStripesPerStripe, 12)
35 def testComparisonOperators(self):
36 c = Chunker(85, 12)
37 self.assertEqual(c, c)
38 self.assertEqual(c, Chunker(85, 12))
39 self.assertNotEqual(c, Chunker(85, 10))
41 def testIntersecting(self):
42 b = Box.fromDegrees(273.6, 30.7, 273.7180105379097, 30.722546655347717)
43 c = Chunker(85, 12)
44 self.assertEqual(c.getChunksIntersecting(b), [9630, 9631, 9797])
45 self.assertEqual(c.getSubChunksIntersecting(b), [(9630, [770]), (9631, [759]), (9797, [11])])
47 def testString(self):
48 chunker = Chunker(85, 12)
49 self.assertEqual(str(chunker), "Chunker(85, 12)")
50 self.assertEqual(repr(chunker), "Chunker(85, 12)")
51 self.assertEqual(chunker, eval(repr(chunker), dict(Chunker=Chunker)))
53 def testPickle(self):
54 a = Chunker(85, 12)
55 b = pickle.loads(pickle.dumps(a))
56 self.assertEqual(a, b)
58 def testChunkBoundingBox(self):
59 chunker = Chunker(200, 5)
60 chunk_id = 3645
61 stripe = chunker.getStripe(chunk_id)
62 chunk_in_stripe = chunker.getChunk(chunk_id, stripe)
63 bbox = chunker.getChunkBoundingBox(stripe, chunk_in_stripe)
64 sbbox = chunker.getSubChunkBoundingBox(0, 0)
65 self.assertEqual(stripe, 9)
66 self.assertEqual(chunk_in_stripe, 45)
67 b = Box.fromRadians(5.048988193233824, -1.4294246573883558, 5.1611879309330035, -1.413716694110407)
68 self.assertAlmostEqual(bbox, b)
69 sb = Box.fromRadians(0.0, -1.5707963267948966, 6.283185307179586, -1.5676547341363067)
70 self.assertAlmostEqual(sbbox, sb)
73if __name__ == "__main__": 73 ↛ 74line 73 didn't jump to line 74, because the condition on line 73 was never true
74 unittest.main()