Coverage for tests/testOpsimUtils.py : 27%

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 matplotlib
2matplotlib.use("Agg")
3import unittest
4import lsst.sims.maf.utils.opsimUtils as opsimUtils
5import lsst.utils.tests
8class TestOpsimUtils(unittest.TestCase):
10 def testScaleBenchmarks(self):
11 """Test scaling the design and stretch benchmarks for the length of the run."""
12 # First test that method returns expected dictionaries.
13 for i in ('design', 'stretch'):
14 benchmark = opsimUtils.scaleBenchmarks(10.0, i)
15 self.assertIsInstance(benchmark, dict)
16 expectedkeys = ('Area', 'nvisitsTotal', 'nvisits', 'seeing', 'skybrightness',
17 'singleVisitDepth')
18 expectedfilters = ('u', 'g', 'r', 'i', 'z', 'y')
19 for k in expectedkeys:
20 self.assertIn(k, benchmark)
21 expecteddictkeys = ('nvisits', 'seeing', 'skybrightness', 'singleVisitDepth')
22 for k in expecteddictkeys:
23 for f in expectedfilters:
24 self.assertIn(f, benchmark[k])
26 def testCalcCoaddedDepth(self):
27 """Test the expected coadded depth calculation."""
28 benchmark = opsimUtils.scaleBenchmarks(10, 'design')
29 coadd = opsimUtils.calcCoaddedDepth(benchmark['nvisits'], benchmark['singleVisitDepth'])
30 for f in coadd:
31 self.assertLess(coadd[f], 1000)
32 singlevisits = {'u': 1, 'g': 1, 'r': 1, 'i': 1, 'z': 1, 'y': 1}
33 coadd = opsimUtils.calcCoaddedDepth(singlevisits, benchmark['singleVisitDepth'])
34 for f in coadd:
35 self.assertAlmostEqual(coadd[f], benchmark['singleVisitDepth'][f])
38class TestMemory(lsst.utils.tests.MemoryTestCase):
39 pass
42def setup_module(module):
43 lsst.utils.tests.init()
46if __name__ == "__main__": 46 ↛ 47line 46 didn't jump to line 47, because the condition on line 46 was never true
47 lsst.utils.tests.init()
48 unittest.main()