From ca70d0d2ad91096bb720a22dd2a04291917dbbef Mon Sep 17 00:00:00 2001 From: Marvin Poul Date: Fri, 3 Apr 2026 17:41:45 -0400 Subject: [PATCH] Make PyACECalculator deal with pickle The default reducer puts out the evaluator and a bunch of other C++ extension types that pickle then chokes on. Side step the problem here by providing a reducer that just makes unpickling equivalent to a new instantiation. The only difficulty here is that basis_set stays a file name if initialized like that and that PyACECalculator.__init__ expects it as a positional argument. Avoid the filename by dumping the whole bbasis config, so that unpickling can happen on other machines or in different locations. --- src/pyace/asecalc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pyace/asecalc.py b/src/pyace/asecalc.py index 359d6f9..da63e66 100644 --- a/src/pyace/asecalc.py +++ b/src/pyace/asecalc.py @@ -212,6 +212,10 @@ def dump_current_configuration(self, atoms, max_gamma): write(fname, atoms, format="cfg") self.current_extrapolation_structure_index += 1 + def __reduce__(self): + di = self.todict() + di.pop('basis_set', None) + return (type(self), (self.basis.to_BBasisConfiguration(),), self.todict()) class PyACEEnsembleCalculator(Calculator): """