Coverage for metadetect / lsst / tests / test_lsst_configs.py: 19%

36 statements  

« prev     ^ index     » next       coverage.py v7.13.2, created at 2026-02-28 01:34 -0800

1""" 

2test configs 

3 

4note we allow the get_all_metacal to do its own verifiction 

5of the metacal sub config 

6""" 

7import pytest 

8 

9from metadetect.lsst.configs import get_config 

10from metadetect.lsst.defaults import DEFAULT_STAMP_SIZE 

11 

12 

13def test_configs_smoke(): 

14 config = get_config() 

15 

16 # make sure the default is verified 

17 get_config(config) 

18 

19 with pytest.raises(ValueError): 

20 get_config({'blah': 3}) 

21 

22 

23@pytest.mark.parametrize('stamp_size', [None, 39]) 

24def test_stamp_size_config(stamp_size): 

25 inconfig = {} 

26 

27 if stamp_size is not None: 

28 inconfig['stamp_size'] = stamp_size 

29 

30 config = get_config(inconfig) 

31 if stamp_size is None: 

32 assert config['stamp_size'] == DEFAULT_STAMP_SIZE 

33 else: 

34 assert config['stamp_size'] == stamp_size 

35 

36 

37def test_pgauss_config(): 

38 # make sure the default is verified 

39 get_config() 

40 inconfig = {} 

41 get_config(inconfig) 

42 

43 fwhm = 1.2 

44 pgauss_conf = {'fwhm': fwhm} 

45 

46 inconfig = {'pgauss': pgauss_conf} 

47 config = get_config(inconfig) 

48 assert config['pgauss']['fwhm'] == fwhm 

49 

50 for key in pgauss_conf: 

51 assert config['pgauss'][key] == pgauss_conf[key] 

52 

53 with pytest.raises(ValueError): 

54 get_config({'pgauss': {'blah': 3}}) 

55 

56 

57def test_detect_config(): 

58 in_config = {'detect': {'thresh': 5}} 

59 config = get_config() 

60 assert config['detect']['thresh'] == in_config['detect']['thresh'] 

61 

62 with pytest.raises(ValueError): 

63 get_config({'detect': {'blah': 5}})