Skip to content

Commit 68cfa83

Browse files
committed
allow replacement of pickle module
1 parent 21c6125 commit 68cfa83

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

py/dynesty/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
import math
1111
import copy
1212
import time
13-
import pickle
1413
import os
1514
from collections import namedtuple
1615
from functools import partial
1716
import numpy as np
1817
from scipy.special import logsumexp
19-
18+
import pickle as pickle_module
19+
# To allow replacing of the pickler
2020
try:
2121
import tqdm
2222
except ImportError:
@@ -1697,7 +1697,7 @@ def restore_sampler(fname, pool=None):
16971697
"""
16981698
from ._version import __version__ as DYNESTY_VERSION
16991699
with open(fname, 'rb') as fp:
1700-
res = pickle.load(fp)
1700+
res = pickle_module.load(fp)
17011701
sampler = res['sampler']
17021702
save_ver = res['version']
17031703
dynesty_format_version = 1
@@ -1744,7 +1744,7 @@ def save_sampler(sampler, fname):
17441744
tmp_fname = fname + '.tmp'
17451745
try:
17461746
with open(tmp_fname, 'wb') as fp:
1747-
pickle.dump(D, fp)
1747+
pickle_module.dump(D, fp)
17481748
os.rename(tmp_fname, fname)
17491749
except: # noqa
17501750
try:

0 commit comments

Comments
 (0)