Python 3 fixes

This commit is contained in:
Mike Croucher 2015-09-07 15:18:45 +01:00
parent 2f0d3b5dcd
commit ec7334846c
3 changed files with 8 additions and 7 deletions

View file

@ -40,7 +40,7 @@ class SparseGPMissing(StochasticStorage):
bdict = {} bdict = {}
#For N > 1000 array2string default crops #For N > 1000 array2string default crops
opt = np.get_printoptions() opt = np.get_printoptions()
np.set_printoptions(threshold='nan') np.set_printoptions(threshold=np.inf)
for d in range(self.Y.shape[1]): for d in range(self.Y.shape[1]):
inan = np.isnan(self.Y)[:, 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'}) 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 = {} bdict = {}
if self.missing_data: if self.missing_data:
opt = np.get_printoptions() opt = np.get_printoptions()
np.set_printoptions(threshold='nan') np.set_printoptions(threshold=np.inf)
for d in self.d: for d in self.d:
inan = np.isnan(self.Y[:, 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'}) arr_str = np.array2string(inan,np.inf, 0,True, '',formatter={'bool':lambda x: '1' if x else '0'})

View file

@ -3,7 +3,7 @@
import numpy as np import numpy as np
from . import Tango 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.gp_coregionalized_regression import GPCoregionalizedRegression
from ...models.sparse_gp_coregionalized_regression import SparseGPCoregionalizedRegression from ...models.sparse_gp_coregionalized_regression import SparseGPCoregionalizedRegression
from scipy import sparse from scipy import sparse
@ -186,8 +186,8 @@ def plot_fit(model, plot_limits=None, which_data_rows='all',
#optionally plot some samples #optionally plot some samples
if samples: #NOTE not tested with fixed_inputs if samples: #NOTE not tested with fixed_inputs
Ysim = model.posterior_samples(Xgrid, samples, Y_metadata=Y_metadata) Ysim = model.posterior_samples(Xgrid, samples, Y_metadata=Y_metadata)
print Ysim.shape print(Ysim.shape)
print Xnew.shape print(Xnew.shape)
for yi in Ysim.T: for yi in Ysim.T:
plots['posterior_samples'] = ax.plot(Xnew, yi[:,None], '#3300FF', linewidth=0.25) 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. #ax.plot(Xnew, yi[:,None], marker='x', linestyle='--',color=Tango.colorsHex['darkBlue']) #TODO apply this line for discrete outputs.

View file

@ -1,3 +1,4 @@
from __future__ import print_function
import numpy as np import numpy as np
import scipy as sp import scipy as sp
import GPy import GPy
@ -18,8 +19,8 @@ class MiscTests(np.testing.TestCase):
assert np.isinf(np.exp(self._lim_val_exp + 1)) assert np.isinf(np.exp(self._lim_val_exp + 1))
assert np.isfinite(GPy.util.misc.safe_exp(self._lim_val_exp + 1)) assert np.isfinite(GPy.util.misc.safe_exp(self._lim_val_exp + 1))
print w print(w)
print len(w) print(len(w))
assert len(w)==1 # should have one overflow warning assert len(w)==1 # should have one overflow warning
def test_safe_exp_lower(self): def test_safe_exp_lower(self):