mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-27 14:25:16 +02:00
[test] coverage increased
This commit is contained in:
parent
2e4be065d1
commit
844c24247b
26 changed files with 63 additions and 46 deletions
|
|
@ -51,6 +51,7 @@ if config.get('plotting', 'library') is not 'none':
|
|||
|
||||
from ..core import GP
|
||||
GP.plot_data = gpy_plot.data_plots.plot_data
|
||||
GP.plot_data_error = gpy_plot.data_plots.plot_data_error
|
||||
GP.plot_errorbars_trainset = gpy_plot.data_plots.plot_errorbars_trainset
|
||||
GP.plot_mean = gpy_plot.gp_plots.plot_mean
|
||||
GP.plot_confidence = gpy_plot.gp_plots.plot_confidence
|
||||
|
|
|
|||
|
|
@ -134,24 +134,23 @@ def _plot_data_error(self, canvas, which_data_rows='all',
|
|||
plots = {}
|
||||
|
||||
if X_variance is not None:
|
||||
plots['xerrorplot'] = []
|
||||
plots['input_error'] = []
|
||||
#one dimensional plotting
|
||||
if len(free_dims) == 1:
|
||||
for d in ycols:
|
||||
update_not_existing_kwargs(error_kwargs, pl().defaults.xerrorbar)
|
||||
plots['xerrorplot'].append(pl().xerrorbar(canvas, X[rows, free_dims].flatten(), Y[rows, d].flatten(),
|
||||
plots['input_error'].append(pl().xerrorbar(canvas, X[rows, free_dims].flatten(), Y[rows, d].flatten(),
|
||||
2 * np.sqrt(X_variance[rows, free_dims].flatten()), label=label,
|
||||
**error_kwargs))
|
||||
#2D plotting
|
||||
elif len(free_dims) == 2:
|
||||
update_not_existing_kwargs(error_kwargs, pl().defaults.xerrorbar) # @UndefinedVariable
|
||||
for d in ycols:
|
||||
plots['xerrorplot'].append(pl().xerrorbar(canvas, X[rows, free_dims[0]].flatten(), Y[rows, d].flatten(),
|
||||
2 * np.sqrt(X_variance[rows, free_dims[0]].flatten()), label=label,
|
||||
**error_kwargs))
|
||||
plots['yerrorplot'].append(pl().xerrorbar(canvas, X[rows, free_dims[1]].flatten(), Y[rows, d].flatten(),
|
||||
2 * np.sqrt(X_variance[rows, free_dims[1]].flatten()), label=label,
|
||||
**error_kwargs))
|
||||
plots['input_error'].append(pl().xerrorbar(canvas, X[rows, free_dims[0]].flatten(), X[rows, free_dims[1]].flatten(),
|
||||
2 * np.sqrt(X_variance[rows, free_dims[0]].flatten()), label=label,
|
||||
**error_kwargs))
|
||||
plots['input_error'].append(pl().yerrorbar(canvas, X[rows, free_dims[0]].flatten(), X[rows, free_dims[1]].flatten(),
|
||||
2 * np.sqrt(X_variance[rows, free_dims[1]].flatten()), label=label,
|
||||
**error_kwargs))
|
||||
elif len(free_dims) == 0:
|
||||
pass #Nothing to plot!
|
||||
else:
|
||||
|
|
@ -244,7 +243,7 @@ def _plot_errorbars_trainset(self, canvas,
|
|||
|
||||
plots = []
|
||||
|
||||
if len(free_dims)<=2:
|
||||
if len(free_dims)<=2 and projection=='2d':
|
||||
update_not_existing_kwargs(plot_kwargs, pl().defaults.yerrorbar)
|
||||
if predict_kw is None:
|
||||
predict_kw = {}
|
||||
|
|
@ -259,21 +258,20 @@ def _plot_errorbars_trainset(self, canvas,
|
|||
np.vstack([mu[rows, d] - percs[0][rows, d], percs[1][rows, d] - mu[rows,d]]),
|
||||
label=label,
|
||||
**plot_kwargs))
|
||||
elif len(free_dims) == 2:
|
||||
for d in ycols:
|
||||
plots.append(pl().yerrorbar(canvas, X[rows,free_dims[0]], X[rows,free_dims[1]],
|
||||
np.vstack([mu[rows, d] - percs[0][rows, d], percs[1][rows, d] - mu[rows,d]]),
|
||||
color=Y[rows,d],
|
||||
label=label,
|
||||
**plot_kwargs))
|
||||
plots.append(pl().xerrorbar(canvas, X[rows,free_dims[0]], X[rows,free_dims[1]],
|
||||
np.vstack([mu[rows, d] - percs[0][rows, d], percs[1][rows, d] - mu[rows,d]]),
|
||||
color=Y[rows,d],
|
||||
label=label,
|
||||
**plot_kwargs))
|
||||
pass #Nothing to plot!
|
||||
# elif len(free_dims) == 2:
|
||||
# for d in ycols:
|
||||
# plots.append(pl().yerrorbar(canvas, X[rows,free_dims[0]], X[rows,free_dims[1]],
|
||||
# np.vstack([mu[rows, d] - percs[0][rows, d], percs[1][rows, d] - mu[rows,d]]),
|
||||
# #color=Y[rows,d],
|
||||
# label=label,
|
||||
# **plot_kwargs))
|
||||
# plots.append(pl().xerrorbar(canvas, X[rows,free_dims[0]], X[rows,free_dims[1]],
|
||||
# np.vstack([mu[rows, d] - percs[0][rows, d], percs[1][rows, d] - mu[rows,d]]),
|
||||
# #color=Y[rows,d],
|
||||
# label=label,
|
||||
# **plot_kwargs))
|
||||
else:
|
||||
raise NotImplementedError("Cannot plot in more then one dimension.")
|
||||
raise NotImplementedError("Cannot plot in more then one dimensions, or 3d")
|
||||
return dict(yerrorbars=plots)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -205,15 +205,13 @@ def _plot_samples(self, canvas, helper_data, helper_prediction, projection,
|
|||
if len(free_dims)==1:
|
||||
# 1D plotting:
|
||||
update_not_existing_kwargs(kwargs, pl().defaults.samples_1d) # @UndefinedVariable
|
||||
return dict(gpmean=[pl().plot(canvas, Xgrid[:, free_dims], samples, label=label, **kwargs)])
|
||||
plots = [pl().plot(canvas, Xgrid[:, free_dims], samples[:, s], label=label if s==0 else None, **kwargs) for s in range(samples.shape[-1])]
|
||||
elif len(free_dims)==2 and projection=='3d':
|
||||
update_not_existing_kwargs(kwargs, pl().defaults.samples_3d) # @UndefinedVariable
|
||||
for s in range(samples.shape[-1]):
|
||||
return dict(gpmean=[pl().surface(canvas, x,
|
||||
y, samples[:, s].reshape(resolution, resolution),
|
||||
**kwargs)])
|
||||
plots = [pl().surface(canvas, x, y, samples[:, s].reshape(resolution, resolution), **kwargs) for s in range(samples.shape[-1])]
|
||||
else:
|
||||
pass # Nothing to plot!
|
||||
return dict(gpmean=plots)
|
||||
else:
|
||||
raise RuntimeError('Cannot plot mean in more then 1 input dimensions')
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ it gives back an empty default, when defaults are not defined.
|
|||
data_1d = dict(lw=1.5, marker='x', edgecolor='k')
|
||||
data_2d = dict(s=35, edgecolors='none', linewidth=0., cmap=cm.get_cmap('hot'), alpha=.5)
|
||||
inducing_1d = dict(lw=0, s=500, facecolors=Tango.colorsHex['darkRed'])
|
||||
inducing_2d = dict(s=14, edgecolors='k', linewidth=.4, facecolors='white', alpha=.5)
|
||||
inducing_2d = dict(s=14, edgecolors='k', linewidth=.4, facecolors='white', alpha=.5, marker='^')
|
||||
inducing_3d = dict(lw=.3, s=500, facecolors='white', edgecolors='k')
|
||||
xerrorbar = dict(color='k', fmt='none', elinewidth=.5, alpha=.5)
|
||||
yerrorbar = dict(color=Tango.colorsHex['darkRed'], fmt='none', elinewidth=.5, alpha=.5)
|
||||
|
|
|
|||
|
|
@ -127,18 +127,18 @@ class MatplotlibPlots(AbstractPlottingLibrary):
|
|||
bottom=bottom, label=label, color=color,
|
||||
**kwargs)
|
||||
|
||||
def xerrorbar(self, ax, X, Y, error, Z=None, color=Tango.colorsHex['mediumBlue'], label=None, **kwargs):
|
||||
def xerrorbar(self, ax, X, Y, error, color=Tango.colorsHex['mediumBlue'], label=None, **kwargs):
|
||||
if not('linestyle' in kwargs or 'ls' in kwargs):
|
||||
kwargs['ls'] = 'none'
|
||||
if Z is not None:
|
||||
return ax.errorbar(X, Y, Z, xerr=error, ecolor=color, label=label, **kwargs)
|
||||
#if Z is not None:
|
||||
# return ax.errorbar(X, Y, Z, xerr=error, ecolor=color, label=label, **kwargs)
|
||||
return ax.errorbar(X, Y, xerr=error, ecolor=color, label=label, **kwargs)
|
||||
|
||||
def yerrorbar(self, ax, X, Y, error, Z=None, color=Tango.colorsHex['mediumBlue'], label=None, **kwargs):
|
||||
def yerrorbar(self, ax, X, Y, error, color=Tango.colorsHex['mediumBlue'], label=None, **kwargs):
|
||||
if not('linestyle' in kwargs or 'ls' in kwargs):
|
||||
kwargs['ls'] = 'none'
|
||||
if Z is not None:
|
||||
return ax.errorbar(X, Y, Z, yerr=error, ecolor=color, label=label, **kwargs)
|
||||
#if Z is not None:
|
||||
# return ax.errorbar(X, Y, Z, yerr=error, ecolor=color, label=label, **kwargs)
|
||||
return ax.errorbar(X, Y, yerr=error, ecolor=color, label=label, **kwargs)
|
||||
|
||||
def imshow(self, ax, X, extent=None, label=None, vmin=None, vmax=None, **imshow_kwargs):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue