mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-21 14:05:14 +02:00
cPickle fix for Py3
This commit is contained in:
parent
6aca7c2765
commit
46fc08a448
1 changed files with 4 additions and 1 deletions
|
|
@ -110,7 +110,10 @@ class Pickleable(object):
|
||||||
it properly.
|
it properly.
|
||||||
:param protocol: pickling protocol to use, python-pickle for details.
|
:param protocol: pickling protocol to use, python-pickle for details.
|
||||||
"""
|
"""
|
||||||
import cPickle as pickle
|
try: #Py2
|
||||||
|
import cPickle as pickle
|
||||||
|
except ImportError: #Py3
|
||||||
|
import pickle
|
||||||
if isinstance(f, str):
|
if isinstance(f, str):
|
||||||
with open(f, 'wb') as f:
|
with open(f, 'wb') as f:
|
||||||
pickle.dump(self, f, protocol)
|
pickle.dump(self, f, protocol)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue