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

import unittest 

import lsst.sims.utils as utils 

import numpy as np 

 

import lsst.utils.tests 

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

class StellarMagsTest(unittest.TestCase): 

""" 

Test the example stellar colors code 

""" 

 

def testSM(self): 

keys = ['O', 'B', 'A', 'F', 'G', 'K', 'M', 

'HeWD_25200_80', 'WD_11000_85', 'WD_3000_85'] 

filterNames = ['u', 'g', 'r', 'i', 'z', 'y'] 

 

# Check each type returns the correct format 

for key in keys: 

result = utils.stellarMags(key) 

for fn in filterNames: 

self.assertIn(fn, result) 

self.assertTrue((isinstance(result[fn], float)) | 

(isinstance(result[fn], np.float64)), 

msg='result is neither a float nor a numpy float64') 

 

# Check the exception gets raised 

self.assertRaises(ValueError, utils.stellarMags, 'ack') 

 

# Check the mags get fainter 

for st in keys: 

mags = utils.stellarMags(st) 

mags2 = utils.stellarMags(st, rmag=20.) 

for key in mags: 

self.assertLess(mags[key], mags2[key]) 

 

 

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

pass 

 

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()