Coverage for /builds/ericyuan00000/ase/ase/utils/abc.py: 78.26%
23 statements
« prev ^ index » next coverage.py v7.5.3, created at 2025-06-18 01:20 +0000
« prev ^ index » next coverage.py v7.5.3, created at 2025-06-18 01:20 +0000
1# fmt: off
3import collections
4from abc import abstractmethod
6import numpy as np
8# Due to the high prevalence of cyclic imports surrounding ase.optimize,
9# we define the Optimizable ABC here in utils.
10# Can we find a better way?
13class Optimizable(collections.abc.Sized):
14 @abstractmethod
15 def get_positions(self):
16 ...
18 @abstractmethod
19 def set_positions(self, positions):
20 ...
22 @abstractmethod
23 def get_forces(self):
24 ...
26 @abstractmethod
27 def get_potential_energy(self):
28 ...
30 @abstractmethod
31 def iterimages(self):
32 ...
34 def converged(self, forces, fmax):
35 return np.linalg.norm(forces, axis=1).max() < fmax
37 def __ase_optimizable__(self):
38 return self