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