Coverage for pesummary/tests/existing_file.py: 0.0%

33 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-05-02 08:42 +0000

1# Licensed under an MIT style license -- see LICENSE.md 

2 

3import argparse 

4import pesummary 

5 

6__author__ = ["Charlie Hoy <charlie.hoy@ligo.org>"] 

7 

8 

9def command_line(): 

10 """Generate an Argument Parser object to control the command line options 

11 """ 

12 parser = argparse.ArgumentParser(description=__doc__) 

13 parser.add_argument("-f", "--file", help="Result file you wish to test") 

14 parser.add_argument( 

15 "-t", "--type", help="The class you expect to be used to load the file", 

16 default="pesummary.gw.file.formats.pesummary.PESummary" 

17 ) 

18 return parser 

19 

20 

21def test_load_pesummary(file): 

22 """Load a file using PESummary and check that we can access the properties 

23 """ 

24 from pesummary.gw.file.read import read 

25 

26 f = read(file) 

27 assert isinstance(f, pesummary.gw.file.formats.pesummary.PESummary) 

28 samples = f.samples_dict 

29 assert isinstance(samples, dict) 

30 labels = f.labels 

31 assert isinstance(labels, list) 

32 config = f.config 

33 assert isinstance(config, dict) 

34 calibration = f.calibration 

35 assert isinstance(calibration, dict) 

36 psd = f.psd 

37 assert isinstance(psd, dict) 

38 

39 

40def test_load(file, _type): 

41 """Load a file using PESummary and check that we can access the properties 

42 """ 

43 from pesummary.gw.file.read import read 

44 

45 f = read(file) 

46 assert isinstance(f, eval(_type)) 

47 samples = f.samples_dict 

48 assert isinstance(samples, dict) 

49 

50 

51parser = command_line() 

52opts = parser.parse_args() 

53if opts.type == "pesummary.gw.file.formats.pesummary.PESummary": 

54 test_load_pesummary(opts.file) 

55else: 

56 test_load(opts.file, _type=opts.type)