From ec7334846c82634731a4054f3a292c6ca468df83 Mon Sep 17 00:00:00 2001 From: Mike Croucher Date: Mon, 7 Sep 2015 15:18:45 +0100 Subject: [PATCH] Python 3 fixes --- GPy/inference/optimization/stochastics.py | 4 ++-- GPy/plotting/matplot_dep/models_plots.py | 6 +++--- GPy/testing/misc_tests.py | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/GPy/inference/optimization/stochastics.py b/GPy/inference/optimization/stochastics.py index 0fc488a2..902c4290 100644 --- a/GPy/inference/optimization/stochastics.py +++ b/GPy/inference/optimization/stochastics.py @@ -40,7 +40,7 @@ class SparseGPMissing(StochasticStorage): bdict = {} #For N > 1000 array2string default crops opt = np.get_printoptions() - np.set_printoptions(threshold='nan') + np.set_printoptions(threshold=np.inf) for d in range(self.Y.shape[1]): inan = np.isnan(self.Y)[:, d] arr_str = np.array2string(inan, np.inf, 0, True, '', formatter={'bool':lambda x: '1' if x else '0'}) @@ -74,7 +74,7 @@ class SparseGPStochastics(StochasticStorage): bdict = {} if self.missing_data: opt = np.get_printoptions() - np.set_printoptions(threshold='nan') + np.set_printoptions(threshold=np.inf) for d in self.d: inan = np.isnan(self.Y[:, d]) arr_str = np.array2string(inan,np.inf, 0,True, '',formatter={'bool':lambda x: '1' if x else '0'}) diff --git a/GPy/plotting/matplot_dep/models_plots.py b/GPy/plotting/matplot_dep/models_plots.py index 87ffd740..3a5a01d2 100644 --- a/GPy/plotting/matplot_dep/models_plots.py +++ b/GPy/plotting/matplot_dep/models_plots.py @@ -3,7 +3,7 @@ import numpy as np from . import Tango -from base_plots import gpplot, x_frame1D, x_frame2D,gperrors +from .base_plots import gpplot, x_frame1D, x_frame2D,gperrors from ...models.gp_coregionalized_regression import GPCoregionalizedRegression from ...models.sparse_gp_coregionalized_regression import SparseGPCoregionalizedRegression from scipy import sparse @@ -186,8 +186,8 @@ def plot_fit(model, plot_limits=None, which_data_rows='all', #optionally plot some samples if samples: #NOTE not tested with fixed_inputs Ysim = model.posterior_samples(Xgrid, samples, Y_metadata=Y_metadata) - print Ysim.shape - print Xnew.shape + print(Ysim.shape) + print(Xnew.shape) for yi in Ysim.T: plots['posterior_samples'] = ax.plot(Xnew, yi[:,None], '#3300FF', linewidth=0.25) #ax.plot(Xnew, yi[:,None], marker='x', linestyle='--',color=Tango.colorsHex['darkBlue']) #TODO apply this line for discrete outputs. diff --git a/GPy/testing/misc_tests.py b/GPy/testing/misc_tests.py index caf98874..a0e2d949 100644 --- a/GPy/testing/misc_tests.py +++ b/GPy/testing/misc_tests.py @@ -1,3 +1,4 @@ +from __future__ import print_function import numpy as np import scipy as sp import GPy @@ -18,8 +19,8 @@ class MiscTests(np.testing.TestCase): assert np.isinf(np.exp(self._lim_val_exp + 1)) assert np.isfinite(GPy.util.misc.safe_exp(self._lim_val_exp + 1)) - print w - print len(w) + print(w) + print(len(w)) assert len(w)==1 # should have one overflow warning def test_safe_exp_lower(self):