From 0a1b3a909f921c01fcf957b7dc3eae9808348aca Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sat, 10 Oct 2015 23:15:19 +0100 Subject: [PATCH 01/14] Update model_tests.py --- GPy/testing/model_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPy/testing/model_tests.py b/GPy/testing/model_tests.py index d7339dd0..37a8d666 100644 --- a/GPy/testing/model_tests.py +++ b/GPy/testing/model_tests.py @@ -48,7 +48,7 @@ class MiscTests(unittest.TestCase): Y = self.Y mu, std = Y.mean(0), Y.std(0) m = GPy.models.GPRegression(self.X, Y, kernel=k, normalizer=True) - m.optimize() + m.optimize(verbose=True) assert(m.checkgrad()) k = GPy.kern.RBF(1) m2 = GPy.models.GPRegression(self.X, (Y-mu)/std, kernel=k, normalizer=False) From 2dbd7998314c4cccf6cfd9831f2313e079a93da8 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sat, 10 Oct 2015 23:28:33 +0100 Subject: [PATCH 02/14] Update pickle_tests.py --- GPy/testing/pickle_tests.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/GPy/testing/pickle_tests.py b/GPy/testing/pickle_tests.py index 64357b39..2867c2bf 100644 --- a/GPy/testing/pickle_tests.py +++ b/GPy/testing/pickle_tests.py @@ -60,13 +60,15 @@ class Test(ListDictTestCase): pio2 = pickle.load(f) self.assertListDictEquals(pio._properties, pio2._properties) - with tempfile.TemporaryFile('w+b') as f: + f = tempfile.TemporaryFile('w+b') + + with f: pickle.dump(piov, f) - f.seek(0) - pio2 = pickle.load(f) - #py3 fix - #self.assertListDictEquals(dict(piov.items()), dict(pio2.iteritems())) - self.assertListDictEquals(dict(piov.items()), dict(pio2.items())) + + pio2 = GPy.load(f) + #py3 fix + #self.assertListDictEquals(dict(piov.items()), dict(pio2.iteritems())) + self.assertListDictEquals(dict(piov.items()), dict(pio2.items())) def test_param(self): param = Param('test', np.arange(4*2).reshape(4,2)) From 7deb99c80cd46ecb112740cd32cb863ef4005abc Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sat, 10 Oct 2015 23:29:26 +0100 Subject: [PATCH 03/14] Update model_tests.py --- GPy/testing/model_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPy/testing/model_tests.py b/GPy/testing/model_tests.py index 37a8d666..a2ba1575 100644 --- a/GPy/testing/model_tests.py +++ b/GPy/testing/model_tests.py @@ -48,7 +48,7 @@ class MiscTests(unittest.TestCase): Y = self.Y mu, std = Y.mean(0), Y.std(0) m = GPy.models.GPRegression(self.X, Y, kernel=k, normalizer=True) - m.optimize(verbose=True) + m.optimize(messages=True) assert(m.checkgrad()) k = GPy.kern.RBF(1) m2 = GPy.models.GPRegression(self.X, (Y-mu)/std, kernel=k, normalizer=False) From 2371683e745ae90a60d6df373a5cf3ace4036f17 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sun, 11 Oct 2015 00:16:42 +0100 Subject: [PATCH 04/14] Update pickle_tests.py --- GPy/testing/pickle_tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/GPy/testing/pickle_tests.py b/GPy/testing/pickle_tests.py index 2867c2bf..f925c0a1 100644 --- a/GPy/testing/pickle_tests.py +++ b/GPy/testing/pickle_tests.py @@ -21,6 +21,7 @@ from GPy.core.parameterization.variational import NormalPosterior from GPy.models.gp_regression import GPRegression from functools import reduce from GPy.util.caching import Cacher +import GPy from pickle import PicklingError def toy_model(): From 5f52215e6369c3a5802574ba6ad295ce8fde7ea1 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sun, 11 Oct 2015 00:23:21 +0100 Subject: [PATCH 05/14] Update pickle_tests.py --- GPy/testing/pickle_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GPy/testing/pickle_tests.py b/GPy/testing/pickle_tests.py index f925c0a1..05bde22a 100644 --- a/GPy/testing/pickle_tests.py +++ b/GPy/testing/pickle_tests.py @@ -66,7 +66,8 @@ class Test(ListDictTestCase): with f: pickle.dump(piov, f) - pio2 = GPy.load(f) + with open(f): + pio2 = GPy.load(f) #py3 fix #self.assertListDictEquals(dict(piov.items()), dict(pio2.iteritems())) self.assertListDictEquals(dict(piov.items()), dict(pio2.items())) From 1e56fc62c2cdf8cc92f75a9bfe30fdb6b579ee87 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sun, 11 Oct 2015 01:26:03 +0100 Subject: [PATCH 06/14] Update pickle_tests.py --- GPy/testing/pickle_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPy/testing/pickle_tests.py b/GPy/testing/pickle_tests.py index 05bde22a..b01f31a6 100644 --- a/GPy/testing/pickle_tests.py +++ b/GPy/testing/pickle_tests.py @@ -66,7 +66,7 @@ class Test(ListDictTestCase): with f: pickle.dump(piov, f) - with open(f): + with f: pio2 = GPy.load(f) #py3 fix #self.assertListDictEquals(dict(piov.items()), dict(pio2.iteritems())) From fa658fb6221bce1a8e571f0dbc95e588a531479a Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sun, 11 Oct 2015 01:26:55 +0100 Subject: [PATCH 07/14] Update pickle_tests.py --- GPy/testing/pickle_tests.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/GPy/testing/pickle_tests.py b/GPy/testing/pickle_tests.py index b01f31a6..ec9ea3c3 100644 --- a/GPy/testing/pickle_tests.py +++ b/GPy/testing/pickle_tests.py @@ -62,12 +62,11 @@ class Test(ListDictTestCase): self.assertListDictEquals(pio._properties, pio2._properties) f = tempfile.TemporaryFile('w+b') + pickle.dump(piov, f) + f.seek(0) + pio2 = GPy.load(f) + f.close() - with f: - pickle.dump(piov, f) - - with f: - pio2 = GPy.load(f) #py3 fix #self.assertListDictEquals(dict(piov.items()), dict(pio2.iteritems())) self.assertListDictEquals(dict(piov.items()), dict(pio2.items())) From 5c22f022266a1bf3663368088fe7849a610b00d1 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sun, 11 Oct 2015 01:36:03 +0100 Subject: [PATCH 08/14] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index faa73810..fe11e334 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,4 +47,4 @@ deploy: secure: "vMEOlP7DQhFJ7hQAKtKC5hrJXFl5BkUt4nXdosWWiw//Kg8E+PPLg88XPI2gqIosir9wwgtbSBBbbwCxkM6uxRNMpoNR8Ixyv9fmSXp4rLl7bbBY768W7IRXKIBjpuEy2brQjoT+CwDDSzUkckHvuUjJDNRvUv8ab4P/qYO1LG4=" on: plot_density - distributions: "bdist_wheel sdist sphinx_build sphinx_upload" \ No newline at end of file + distributions: "bdist_wheel sdist" From 812d1aa350fe1967a9e00353670630777a3180c0 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sun, 11 Oct 2015 01:41:33 +0100 Subject: [PATCH 09/14] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index fe11e334..6a113313 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,3 +48,4 @@ deploy: on: plot_density distributions: "bdist_wheel sdist" + server: https://testpypi.python.org/pypi From 4787b0dbd26b407f2bb4058ffec76d9d36b7a7e6 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sun, 11 Oct 2015 01:42:49 +0100 Subject: [PATCH 10/14] Update __init__.py --- GPy/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/GPy/__init__.py b/GPy/__init__.py index 5bbdeff8..8af8a4f6 100644 --- a/GPy/__init__.py +++ b/GPy/__init__.py @@ -42,16 +42,20 @@ def load(file_or_path): :param file_name: path/to/file.pickle """ + try: + str = basestring + except: + pass try: import cPickle as pickle - if isinstance(file_or_path, basestring): + if isinstance(file_or_path, str): with open(file_or_path, 'rb') as f: m = pickle.load(f) else: m = pickle.load(file_or_path) except: import pickle - if isinstance(file_or_path, basestring): + if isinstance(file_or_path, str): with open(file_or_path, 'rb') as f: m = pickle.load(f) else: From cca642dd8c83884764192aaa969edd2267ffde10 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sun, 11 Oct 2015 01:48:16 +0100 Subject: [PATCH 11/14] Update plotting_tests.py --- GPy/testing/plotting_tests.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GPy/testing/plotting_tests.py b/GPy/testing/plotting_tests.py index 28eb5c8d..e60928a7 100644 --- a/GPy/testing/plotting_tests.py +++ b/GPy/testing/plotting_tests.py @@ -101,7 +101,9 @@ def test_kernel(): matplotlib.rcParams[u'text.usetex'] = False k = GPy.kern.RBF(5, ARD=True) + GPy.kern.Linear(3, active_dims=[0,2,4], ARD=True) + GPy.kern.Bias(2) k.randomize() - k.plot_ARD(legend=True) + k2 = GPy.kern.RBF(5, ARD=True) + GPy.kern.Linear(3, active_dims=[0,2,4], ARD=True) + GPy.kern.Bias(2) + GPy.kern.White(4) + k2[:-1] = k[:] + k2.plot_ARD([k2.white.name], legend=True) for do_test in _image_comparison( baseline_images=['kern_{}'.format(sub) for sub in ["ARD",]], extensions=extensions): From 0b4297bda54ed9b33c60be01346b1f55c4383d8a Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sun, 11 Oct 2015 01:54:06 +0100 Subject: [PATCH 12/14] Update .travis.yml --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6a113313..6aec1087 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,6 +39,10 @@ script: after_success: - codecov + - conda install sphinx + - cd doc + - make html + - cd ../ deploy: provider: pypi From 0d74681ee26bab705c77ec9ea90dc77212018250 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sun, 11 Oct 2015 01:57:37 +0100 Subject: [PATCH 13/14] Update __init__.py --- GPy/__init__.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/GPy/__init__.py b/GPy/__init__.py index 8af8a4f6..506ad866 100644 --- a/GPy/__init__.py +++ b/GPy/__init__.py @@ -43,19 +43,28 @@ def load(file_or_path): :param file_name: path/to/file.pickle """ try: - str = basestring - except: - pass - try: - import cPickle as pickle - if isinstance(file_or_path, str): - with open(file_or_path, 'rb') as f: - m = pickle.load(f) + unicode = unicode + except NameError: + # 'unicode' is undefined, must be Python 3 + str = str + unicode = str + bytes = bytes + basestring = (str,bytes) + else: + # 'unicode' exists, must be Python 2 + str = str + unicode = unicode + bytes = str + basestring = basestring try: + import cPickle as pickle + if isinstance(file_or_path, basestring): + with open(file_or_path, 'rb') as f: + m = pickle.load(f) else: m = pickle.load(file_or_path) except: import pickle - if isinstance(file_or_path, str): + if isinstance(file_or_path, basestring): with open(file_or_path, 'rb') as f: m = pickle.load(f) else: From c7c18f043711fbc750d3de73a21e4556f1104eb5 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sun, 11 Oct 2015 02:04:16 +0100 Subject: [PATCH 14/14] Update __init__.py --- GPy/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/GPy/__init__.py b/GPy/__init__.py index 506ad866..5af56dc4 100644 --- a/GPy/__init__.py +++ b/GPy/__init__.py @@ -55,11 +55,12 @@ def load(file_or_path): str = str unicode = unicode bytes = str - basestring = basestring try: - import cPickle as pickle - if isinstance(file_or_path, basestring): - with open(file_or_path, 'rb') as f: - m = pickle.load(f) + basestring = basestring + try: + import cPickle as pickle + if isinstance(file_or_path, basestring): + with open(file_or_path, 'rb') as f: + m = pickle.load(f) else: m = pickle.load(file_or_path) except: