Coverage for tests/testStellarMags.py : 31%

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
1import unittest
2import lsst.sims.utils as utils
3import numpy as np
5import lsst.utils.tests
8def setup_module(module):
9 lsst.utils.tests.init()
12class StellarMagsTest(unittest.TestCase):
13 """
14 Test the example stellar colors code
15 """
17 def testSM(self):
18 keys = ['O', 'B', 'A', 'F', 'G', 'K', 'M',
19 'HeWD_25200_80', 'WD_11000_85', 'WD_3000_85']
20 filterNames = ['u', 'g', 'r', 'i', 'z', 'y']
22 # Check each type returns the correct format
23 for key in keys:
24 result = utils.stellarMags(key)
25 for fn in filterNames:
26 self.assertIn(fn, result)
27 self.assertTrue((isinstance(result[fn], float)) |
28 (isinstance(result[fn], np.float64)),
29 msg='result is neither a float nor a numpy float64')
31 # Check the exception gets raised
32 self.assertRaises(ValueError, utils.stellarMags, 'ack')
34 # Check the mags get fainter
35 for st in keys:
36 mags = utils.stellarMags(st)
37 mags2 = utils.stellarMags(st, rmag=20.)
38 for key in mags:
39 self.assertLess(mags[key], mags2[key])
42class MemoryTestClass(lsst.utils.tests.MemoryTestCase):
43 pass
45if __name__ == "__main__": 45 ↛ 46line 45 didn't jump to line 46, because the condition on line 45 was never true
46 lsst.utils.tests.init()
47 unittest.main()