From aff10f31432cb06efd4436ce893e4dd0dc285bc1 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Thu, 9 Apr 2020 22:37:47 +0200 Subject: [PATCH] make BalancingLearner picklable --- adaptive/learner/balancing_learner.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/adaptive/learner/balancing_learner.py b/adaptive/learner/balancing_learner.py index ce40afb22..13d61a503 100644 --- a/adaptive/learner/balancing_learner.py +++ b/adaptive/learner/balancing_learner.py @@ -440,3 +440,16 @@ def _get_data(self): def _set_data(self, data): for l, _data in zip(self.learners, data): l._set_data(_data) + + def __getstate__(self): + return ( + self.learners, + self.cdims, + self.strategy, + self._get_data(), + ) + + def __setstate__(self, state): + learners, cdims, strategy, data = state + self.__init__(learners, cdims=cdims, strategy=strategy) + self._set_data(data)