Skip to content

Commit 700bbc8

Browse files
committed
use cloudpickle in save and load
1 parent 90b250b commit 700bbc8

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

adaptive/learner/learnerND.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import random
44
from collections import OrderedDict
55
from collections.abc import Iterable
6+
from copy import deepcopy
67

7-
import cloudpickle
88
import numpy as np
99
import scipy.spatial
1010
from scipy import interpolate
@@ -1180,9 +1180,8 @@ def _get_plane_color(simplex):
11801180
)
11811181

11821182
def _get_data(self):
1183-
return cloudpickle.dumps(self.__dict__)
1183+
return deepcopy(self.__dict__)
11841184

11851185
def _set_data(self, state):
1186-
state = cloudpickle.loads(state)
11871186
for k, v in state.items():
11881187
setattr(self, k, v)

adaptive/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from contextlib import contextmanager
77
from itertools import product
88

9+
import cloudpickle
910
from atomicwrites import AtomicWriter
1011

1112

@@ -46,7 +47,7 @@ def save(fname, data, compress=True):
4647
if dirname:
4748
os.makedirs(dirname, exist_ok=True)
4849

49-
blob = pickle.dumps(data, protocol=pickle.HIGHEST_PROTOCOL)
50+
blob = cloudpickle.dumps(data, protocol=pickle.HIGHEST_PROTOCOL)
5051
if compress:
5152
blob = gzip.compress(blob)
5253

@@ -58,7 +59,7 @@ def load(fname, compress=True):
5859
fname = os.path.expanduser(fname)
5960
_open = gzip.open if compress else open
6061
with _open(fname, "rb") as f:
61-
return pickle.load(f)
62+
return cloudpickle.load(f)
6263

6364

6465
def copy_docstring_from(other):

0 commit comments

Comments
 (0)