Coverage for tests/testStringCount.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
1import matplotlib
2matplotlib.use("Agg")
3import numpy as np
4import unittest
5import lsst.sims.maf.metrics as metrics
6import lsst.utils.tests
9class TestStringCount(unittest.TestCase):
11 def testsc(self):
12 metric = metrics.StringCountMetric()
13 data = np.array(['a', 'a', 'b', 'c', '', '', ''])
14 dt = np.dtype([('filter', np.str_, 1)])
15 data.dtype = dt
16 result = metric.run(data)
17 # Check that the metricValue is correct
18 expected_results = {'a': 2, 'b': 1, 'c': 1, 'blank': 3}
19 for key in expected_results:
20 assert(result[key] == expected_results[key])
22 # Check that the reduce functions got made and return expected result
23 for key in expected_results:
24 assert(metric.reduceFuncs[key](result) == expected_results[key])
27class TestMemory(lsst.utils.tests.MemoryTestCase):
28 pass
31def setup_module(module):
32 lsst.utils.tests.init()
35if __name__ == "__main__": 35 ↛ 36line 35 didn't jump to line 36, because the condition on line 35 was never true
36 lsst.utils.tests.init()
37 unittest.main()