Browse code

make IntegratorLearner picklable

Bas Nijholt authored on 09/04/2020 22:33:29
Showing 1 changed files
... ...
@@ -591,3 +591,16 @@ class IntegratorLearner(BaseLearner):
591 591
         self.x_mapping = defaultdict(lambda: SortedSet([], key=attrgetter("rdepth")))
592 592
         for k, _set in x_mapping.items():
593 593
             self.x_mapping[k].update(_set)
594
+
595
+    def __getstate__(self):
596
+        return (
597
+            self.function,
598
+            self.bounds,
599
+            self.tol,
600
+            self._get_data(),
601
+        )
602
+
603
+    def __setstate__(self, state):
604
+        function, bounds, tol, data = state
605
+        self.__init__(function, bounds, tol)
606
+        self._set_data(data)