Browse code

make AverageLearner picklable

Bas Nijholt authored on 09/04/2020 22:28:58
Showing 1 changed files
... ...
@@ -144,3 +144,16 @@ class AverageLearner(BaseLearner):
144 144
 
145 145
     def _set_data(self, data):
146 146
         self.data, self.npoints, self.sum_f, self.sum_f_sq = data
147
+
148
+    def __getstate__(self):
149
+        return (
150
+            self.function,
151
+            self.atol,
152
+            self.rtol,
153
+            self._get_data(),
154
+        )
155
+
156
+    def __setstate__(self, state):
157
+        function, atol, rtol, data = state
158
+        self.__init__(function, atol, rtol)
159
+        self._set_data(data)