Coverage for /builds/debichem-team/python-ase/ase/calculators/names.py: 64.71%

17 statements  

« prev     ^ index     » next       coverage.py v7.5.3, created at 2025-03-06 04:00 +0000

1import importlib 

2from collections.abc import Mapping 

3 

4# Recognized names of calculators sorted alphabetically: 

5names = ['abinit', 'ace', 'aims', 'amber', 'asap', 'castep', 'cp2k', 

6 'crystal', 'demon', 'demonnano', 'dftb', 'dftd3', 'dmol', 'eam', 

7 'elk', 'emt', 'espresso', 'exciting', 'ff', 'gamess_us', 

8 'gaussian', 'gpaw', 'gromacs', 'gulp', 'hotbit', 'kim', 

9 'lammpslib', 'lammpsrun', 'lj', 'mopac', 'morse', 'nwchem', 

10 'octopus', 'onetep', 'openmx', 'orca', 

11 'plumed', 'psi4', 'qchem', 'siesta', 

12 'tip3p', 'tip4p', 'turbomole', 'vasp'] 

13 

14 

15builtin = {'eam', 'emt', 'ff', 'lj', 'morse', 'tip3p', 'tip4p'} 

16 

17 

18class Templates(Mapping): 

19 def __init__(self, dct): 

20 self._dct = dct 

21 

22 def __iter__(self): 

23 return iter(self._dct) 

24 

25 def __getitem__(self, index): 

26 importpath, clsname = self._dct[index].rsplit('.', 1) 

27 module = importlib.import_module(importpath) 

28 cls = getattr(module, clsname) 

29 return cls() 

30 

31 def __len__(self): 

32 return len(self._dct) 

33 

34 

35templates = Templates({ 

36 'abinit': 'ase.calculators.abinit.AbinitTemplate', 

37 'aims': 'ase.calculators.aims.AimsTemplate', 

38 'espresso': 'ase.calculators.espresso.EspressoTemplate', 

39 'octopus': 'ase.calculators.octopus.OctopusTemplate', 

40})