Coverage for tests/testHourglassMetric.py : 42%

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
1from builtins import zip
2import matplotlib
3matplotlib.use("Agg")
4import numpy as np
5import unittest
6import lsst.sims.maf.metrics as metrics
7import lsst.utils.tests
10class TestHourglassmetric(unittest.TestCase):
12 @unittest.skip("5 April 2016 -- this test causes a malloc error")
13 def testHourglassMetric(self):
14 """Test the hourglass metric """
15 names = ['expMJD', 'night', 'filter']
16 types = [float, float, str]
17 npts = 50
18 data = np.zeros(npts, dtype=list(zip(names, types)))
19 day0 = 59000
20 data['expMJD'] = np.arange(0, 10, .2)[:npts] + day0
21 data['night'] = np.floor(data['expMJD']-day0)
22 data['filter'] = 'r'
23 data['filter'][-1] = 'g'
24 slicePoint = [0]
25 metric = metrics.HourglassMetric()
26 result = metric.run(data, slicePoint)
27 pernight = result['pernight']
28 perfilter = result['perfilter']
30 assert(np.size(pernight) == np.size(np.unique(data['night'])))
31 # All the gaps are larger than 2 min.
32 assert(np.size(perfilter) == 2*data.size)
33 # Check that the format is right at least
34 assert(len(pernight.dtype.names) == 9)
37class TestMemory(lsst.utils.tests.MemoryTestCase):
38 pass
41def setup_module(module):
42 lsst.utils.tests.init()
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()