Coverage for /builds/ase/ase/ase/cluster/util.py: 71.43%

14 statements  

« prev     ^ index     » next       coverage.py v7.5.3, created at 2025-08-02 00:12 +0000

1# fmt: off 

2 

3from ase.data import atomic_numbers, chemical_symbols, reference_states 

4 

5 

6def get_element_info(symbol, latticeconstant): 

7 if isinstance(symbol, str): 

8 atomic_number = atomic_numbers[symbol] 

9 else: 

10 atomic_number = symbol 

11 symbol = chemical_symbols[atomic_number] 

12 

13 if latticeconstant is None: 

14 if reference_states[atomic_number]['symmetry'] in ['fcc', 'bcc', 'sc']: 

15 lattice_constant = reference_states[atomic_number]['a'] 

16 else: 

17 raise NotImplementedError( 

18 "Cannot guess lattice constant of a %s element." % 

19 (reference_states[atomic_number]['symmetry'],)) 

20 else: 

21 if isinstance(latticeconstant, (int, float)): 

22 lattice_constant = latticeconstant 

23 else: 

24 raise ValueError("Lattice constant must be of type int or float.") 

25 

26 return symbol, atomic_number, lattice_constant