Skip to content

Commit 8dfaa6c

Browse files
committed
make LearnerND picklable
1 parent c820704 commit 8dfaa6c

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

adaptive/learner/learnerND.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -988,13 +988,6 @@ def plot_3D(self, with_triangulation=False):
988988

989989
return plotly.offline.iplot(fig)
990990

991-
def _get_data(self):
992-
return self.data
993-
994-
def _set_data(self, data):
995-
if data:
996-
self.tell_many(*zip(*data.items()))
997-
998991
def _get_iso(self, level=0.0, which="surface"):
999992
if which == "surface":
1000993
if self.ndim != 3 or self.vdim != 1:
@@ -1182,3 +1175,23 @@ def _get_plane_color(simplex):
11821175
opacity=opacity,
11831176
lighting=lighting,
11841177
)
1178+
1179+
def _get_data(self):
1180+
return self.data
1181+
1182+
def _set_data(self, data):
1183+
if data:
1184+
self.tell_many(*zip(*data.items()))
1185+
1186+
def __getstate__(self):
1187+
return (
1188+
self.function,
1189+
self.bounds,
1190+
self.loss_per_simplex,
1191+
self._get_data(),
1192+
)
1193+
1194+
def __setstate__(self, state):
1195+
function, bounds, loss_per_simplex, data = state
1196+
self.__init__(function, bounds, loss_per_simplex)
1197+
self._set_data(data)

0 commit comments

Comments
 (0)