Hide keyboard shortcuts

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

from builtins import zip 

import matplotlib 

matplotlib.use("Agg") 

import numpy as np 

import unittest 

import lsst.sims.maf.metrics as metrics 

import lsst.utils.tests 

 

 

class TestHourglassmetric(unittest.TestCase): 

 

@unittest.skip("5 April 2016 -- this test causes a malloc error") 

def testHourglassMetric(self): 

"""Test the hourglass metric """ 

names = ['expMJD', 'night', 'filter'] 

types = [float, float, str] 

npts = 50 

data = np.zeros(npts, dtype=list(zip(names, types))) 

day0 = 59000 

data['expMJD'] = np.arange(0, 10, .2)[:npts] + day0 

data['night'] = np.floor(data['expMJD']-day0) 

data['filter'] = 'r' 

data['filter'][-1] = 'g' 

slicePoint = [0] 

metric = metrics.HourglassMetric() 

result = metric.run(data, slicePoint) 

pernight = result['pernight'] 

perfilter = result['perfilter'] 

 

assert(np.size(pernight) == np.size(np.unique(data['night']))) 

# All the gaps are larger than 2 min. 

assert(np.size(perfilter) == 2*data.size) 

# Check that the format is right at least 

assert(len(pernight.dtype.names) == 9) 

 

 

class TestMemory(lsst.utils.tests.MemoryTestCase): 

pass 

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

45 ↛ 46line 45 didn't jump to line 46, because the condition on line 45 was never trueif __name__ == "__main__": 

lsst.utils.tests.init() 

unittest.main()