Coverage for /builds/kinetik161/ase/ase/calculators/names.py: 88.24%

17 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-12-10 11:04 +0000

1from collections.abc import Mapping 

2import importlib 

3 

4 

5# Recognized names of calculators sorted alphabetically: 

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

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

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

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

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

11 'octopus', 'onetep', 'openmx', 'orca', 

12 'plumed', 'psi4', 'qchem', 'siesta', 

13 'tip3p', 'tip4p', 'turbomole', 'vasp'] 

14 

15 

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

17 

18 

19class Templates(Mapping): 

20 def __init__(self, dct): 

21 self._dct = dct 

22 

23 def __iter__(self): 

24 return iter(self._dct) 

25 

26 def __getitem__(self, index): 

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

28 module = importlib.import_module(importpath) 

29 cls = getattr(module, clsname) 

30 return cls() 

31 

32 def __len__(self): 

33 return len(self._dct) 

34 

35 

36templates = Templates({ 

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

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

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

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

41})