Coverage for /builds/kinetik161/ase/ase/utils/abc.py: 80.00%

25 statements  

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

1import collections 

2from abc import abstractmethod 

3 

4import numpy as np 

5 

6# Due to the high prevalence of cyclic imports surrounding ase.optimize, 

7# we define the Optimizable ABC here in utils. 

8# Can we find a better way? 

9 

10 

11class Optimizable(collections.abc.Sized): 

12 @abstractmethod 

13 def get_positions(self): 

14 ... 

15 

16 @abstractmethod 

17 def set_positions(self, positions): 

18 ... 

19 

20 @abstractmethod 

21 def get_forces(self): 

22 ... 

23 

24 @abstractmethod 

25 def get_potential_energy(self): 

26 ... 

27 

28 @abstractmethod 

29 def iterimages(self): 

30 ... 

31 

32 def converged(self, forces, fmax): 

33 return np.linalg.norm(forces, axis=1).max() < fmax 

34 

35 def is_neb(self): 

36 return False 

37 

38 def __ase_optimizable__(self): 

39 return self