Coverage for tests/test_associationUtils.py: 40%
28 statements
« prev ^ index » next coverage.py v7.2.1, created at 2023-03-12 21:44 -0700
« prev ^ index » next coverage.py v7.2.1, created at 2023-03-12 21:44 -0700
1# This file is part of pipe_tasks.
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22import hpgeom as hpg
23import numpy as np
24import unittest
26from lsst.pipe.tasks.associationUtils import query_disc
27import lsst.utils.tests
30class TestAssociationUtils(lsst.utils.tests.TestCase):
32 def test_queryDisc(self):
33 """Test that doing a circle query of hpgeom using our wrapper works as
34 expected.
36 Most other calculations are very simple and not worth testing.
37 """
38 # Find nearest pixel to r=45, dec=45.
39 nside = 128
40 testRa = 225
41 testDec = 45
42 centerPixNumber = hpg.angle_to_pixel(nside, testRa, testDec, nest=False)
43 ra, dec = hpg.pixel_to_angle(nside, centerPixNumber, nest=False)
44 # Test that only one pixel is found.
45 pixelReturn = query_disc(nside, ra, dec, np.radians(0.1))
46 self.assertEqual(len(pixelReturn), 1)
47 self.assertTrue(centerPixNumber in pixelReturn)
48 # Test that nearby pixels are returned.
49 pixelReturn = query_disc(nside, ra, dec, np.radians(1))
50 self.assertEqual(len(pixelReturn), 17)
51 self.assertTrue(centerPixNumber in pixelReturn)
52 # Test excluding the central pixel
53 pixelReturn = query_disc(
54 nside, ra, dec, np.radians(1), np.radians(0.01))
55 self.assertEqual(len(pixelReturn), 16)
56 self.assertFalse(centerPixNumber in pixelReturn)
59class MemoryTestCase(lsst.utils.tests.MemoryTestCase):
60 pass
63def setup_module(module):
64 lsst.utils.tests.init()
67if __name__ == "__main__": 67 ↛ 68line 67 didn't jump to line 68, because the condition on line 67 was never true
68 lsst.utils.tests.init()
69 unittest.main()