mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-07-02 16:01:03 +02:00
[devel] pickling files...
This commit is contained in:
parent
5d605277bc
commit
0fb7cf2ff3
4 changed files with 33 additions and 25 deletions
|
|
@ -14,9 +14,16 @@ from . import testing
|
||||||
from . import kern
|
from . import kern
|
||||||
from . import plotting
|
from . import plotting
|
||||||
|
|
||||||
|
# backwards compatibility
|
||||||
|
import sys
|
||||||
|
backwards_compatibility = ['lists_and_dicts', 'observable_array', 'ties_and_remappings', 'index_operations']
|
||||||
|
for bc in backwards_compatibility:
|
||||||
|
sys.modules['GPy.core.parameterization.{!s}'.format(bc)] = getattr(core.parameterization, bc)
|
||||||
|
|
||||||
|
|
||||||
# Direct imports for convenience:
|
# Direct imports for convenience:
|
||||||
from .core import Model
|
from .core import Model
|
||||||
from GPy.core.parameterization import priors
|
from .core.parameterization import priors
|
||||||
from paramz import Param, Parameterized, ObsAr, transformations as constraints
|
from paramz import Param, Parameterized, ObsAr, transformations as constraints
|
||||||
|
|
||||||
from .__version__ import __version__
|
from .__version__ import __version__
|
||||||
|
|
@ -40,27 +47,23 @@ def load(file_or_path):
|
||||||
:param file_name: path/to/file.pickle
|
:param file_name: path/to/file.pickle
|
||||||
"""
|
"""
|
||||||
# This is the pickling pain when changing _src -> src
|
# This is the pickling pain when changing _src -> src
|
||||||
|
import inspect
|
||||||
|
sys.modules['GPy.kern._src'] = kern.src
|
||||||
|
for name, module in inspect.getmembers(kern.src):
|
||||||
|
if not name.startswith('_'):
|
||||||
|
sys.modules['GPy.kern._src.{}'.format(name)] = module
|
||||||
try:
|
try:
|
||||||
try:
|
import cPickle as pickle
|
||||||
import cPickle as pickle
|
if isinstance(file_or_path, basestring):
|
||||||
if isinstance(file_or_path, basestring):
|
with open(file_or_path, 'rb') as f:
|
||||||
with open(file_or_path, 'rb') as f:
|
m = pickle.load(f)
|
||||||
m = pickle.load(f)
|
else:
|
||||||
else:
|
m = pickle.load(file_or_path)
|
||||||
m = pickle.load(file_or_path)
|
except:
|
||||||
except:
|
import pickle
|
||||||
import pickle
|
if isinstance(file_or_path, str):
|
||||||
if isinstance(file_or_path, str):
|
with open(file_or_path, 'rb') as f:
|
||||||
with open(file_or_path, 'rb') as f:
|
m = pickle.load(f)
|
||||||
m = pickle.load(f)
|
else:
|
||||||
else:
|
m = pickle.load(file_or_path)
|
||||||
m = pickle.load(file_or_path)
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
import inspect
|
|
||||||
sys.modules['GPy.kern._src'] = kern.src
|
|
||||||
for name, module in inspect.getmembers(kern.src):
|
|
||||||
if not name.startswith('_'):
|
|
||||||
sys.modules['GPy.kern._src.{}'.format(name)] = module
|
|
||||||
m = load(file_or_path)
|
|
||||||
return m
|
return m
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
from GPy.core.model import Model
|
from GPy.core.model import Model
|
||||||
from .parameterization import Param, Parameterized
|
from .parameterization import Param, Parameterized
|
||||||
|
import parameterization
|
||||||
|
|
||||||
from .gp import GP
|
from .gp import GP
|
||||||
from .svgp import SVGP
|
from .svgp import SVGP
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,7 @@
|
||||||
|
|
||||||
from .param import Param
|
from .param import Param
|
||||||
from .parameterized import Parameterized
|
from .parameterized import Parameterized
|
||||||
from paramz import transformations
|
from paramz import transformations
|
||||||
|
|
||||||
|
from paramz.core import lists_and_dicts, index_operations, observable_array, observable
|
||||||
|
from paramz import ties_and_remappings
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import time
|
import time
|
||||||
from .*core.variational import VariationalPosterior
|
from ...core.parameterization.variational import VariationalPosterior
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import matplotlib as mpl
|
import matplotlib as mpl
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue