Coverage for hiphive/config.py: 100%

Shortcuts 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

16 statements  

1from hiphive.input_output.logging_tools import logger 

2 

3 

4logger = logger.getChild(__name__) 

5 

6default_config = { 

7 'acoustic_sum_rules': True, 

8 'symprec': 1e-5, 

9 'length_scale': 0.1, 

10 'intprec': 1e-12, 

11 'standardize_prototype': True, 

12 'shell_tolerance': 1e-5, 

13 'max_number_constraint_elements': 1e8 

14 } 

15 

16 

17class Config(dict): 

18 def __init__(self, **kwargs): 

19 super().__init__(**default_config) 

20 if 'sum_rules' in kwargs: 

21 logger.warning('kw sum_rules deprecated.' 

22 ' Use acoustic_sum_rules instead') 

23 kwargs['acoustic_sum_rules'] = kwargs['sum_rules'] 

24 del kwargs['sum_rules'] 

25 for k, v in kwargs.items(): 

26 if k not in default_config: 

27 raise ValueError('{} is not a valid setting'.format(k)) 

28 if type(default_config[k]) != type(v): 

29 raise TypeError('Value {} of kw {} is not a valid type' 

30 .format(v, k)) 

31 super().update(kwargs)