mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-07-23 17:01:06 +02:00
[tests] now working?
This commit is contained in:
parent
94e8f47e3e
commit
7d90630c1b
3 changed files with 23 additions and 8 deletions
|
|
@ -57,10 +57,20 @@ class AbstractPlottingLibrary(object):
|
||||||
return self.__defaults
|
return self.__defaults
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
def get_new_canvas(self, projection='2d', legend=True, **kwargs):
|
def figure(self, nrows, ncols, **kwargs):
|
||||||
|
"""
|
||||||
|
Get a new figure with nrows and ncolumns subplots.
|
||||||
|
Does not initialize the canvases yet.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError("Implement all plot functions in AbstractPlottingLibrary in order to use your own plotting library")
|
||||||
|
|
||||||
|
def get_new_canvas(self, projection='2d', figure=None, col=1, row=1, **kwargs):
|
||||||
"""
|
"""
|
||||||
Return a canvas, kwargupdate for your plotting library.
|
Return a canvas, kwargupdate for your plotting library.
|
||||||
|
|
||||||
|
if figure is not None, create a canvas in the figure
|
||||||
|
at subplot position (col, row).
|
||||||
|
|
||||||
This method does two things, it creates an empty canvas
|
This method does two things, it creates an empty canvas
|
||||||
and updates the kwargs (deletes the unnecessary kwargs)
|
and updates the kwargs (deletes the unnecessary kwargs)
|
||||||
for further usage in normal plotting.
|
for further usage in normal plotting.
|
||||||
|
|
@ -74,7 +84,7 @@ class AbstractPlottingLibrary(object):
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError("Implement all plot functions in AbstractPlottingLibrary in order to use your own plotting library")
|
raise NotImplementedError("Implement all plot functions in AbstractPlottingLibrary in order to use your own plotting library")
|
||||||
|
|
||||||
def show_canvas(self, canvas, plots, xlabel=None, ylabel=None, zlabel=None, title=None, xlim=None, ylim=None, zlim=None, **kwargs):
|
def show_canvas(self, canvas, plots, xlabel=None, ylabel=None, zlabel=None, title=None, xlim=None, ylim=None, zlim=None, legend=True, **kwargs):
|
||||||
"""
|
"""
|
||||||
Show the canvas given.
|
Show the canvas given.
|
||||||
plots is a dictionary with the plots
|
plots is a dictionary with the plots
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,12 @@ class MatplotlibPlots(AbstractPlottingLibrary):
|
||||||
super(MatplotlibPlots, self).__init__()
|
super(MatplotlibPlots, self).__init__()
|
||||||
self._defaults = defaults.__dict__
|
self._defaults = defaults.__dict__
|
||||||
|
|
||||||
def get_new_canvas(self, projection='2d', **kwargs):
|
def figure(self, rows=1, cols=1, **kwargs):
|
||||||
|
self.rows = rows
|
||||||
|
self.cols = cols
|
||||||
|
return plt.figure(**kwargs)
|
||||||
|
|
||||||
|
def get_new_canvas(self, projection='2d', figure=None, col=1, row=1, **kwargs):
|
||||||
if projection == '3d':
|
if projection == '3d':
|
||||||
from mpl_toolkits.mplot3d import Axes3D
|
from mpl_toolkits.mplot3d import Axes3D
|
||||||
elif projection == '2d':
|
elif projection == '2d':
|
||||||
|
|
@ -50,13 +55,13 @@ class MatplotlibPlots(AbstractPlottingLibrary):
|
||||||
if 'ax' in kwargs:
|
if 'ax' in kwargs:
|
||||||
ax = kwargs.pop('ax')
|
ax = kwargs.pop('ax')
|
||||||
elif 'num' in kwargs and 'figsize' in kwargs:
|
elif 'num' in kwargs and 'figsize' in kwargs:
|
||||||
ax = plt.figure(num=kwargs.pop('num'), figsize=kwargs.pop('figsize')).add_subplot(rows, cols, which, projection=projection)
|
fig = self.figure(num=kwargs.pop('num'), figsize=kwargs.pop('figsize')).add_subplot(111, projection=projection)
|
||||||
elif 'num' in kwargs:
|
elif 'num' in kwargs:
|
||||||
ax = plt.figure(num=kwargs.pop('num')).add_subplot(111, projection=projection)
|
ax = self.figure(num=kwargs.pop('num')).add_subplot(111, projection=projection)
|
||||||
elif 'figsize' in kwargs:
|
elif 'figsize' in kwargs:
|
||||||
ax = plt.figure(figsize=kwargs.pop('figsize')).add_subplot(111, projection=projection)
|
ax = self.figure(figsize=kwargs.pop('figsize')).add_subplot(111, projection=projection)
|
||||||
else:
|
else:
|
||||||
ax = plt.figure().add_subplot(111, projection=projection)
|
ax = self.figure().add_subplot(111, projection=projection)
|
||||||
|
|
||||||
return ax, kwargs
|
return ax, kwargs
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,5 +38,5 @@ matplotlib.rcParams[u'figure.figsize'] = (4,3)
|
||||||
matplotlib.rcParams[u'text.usetex'] = False
|
matplotlib.rcParams[u'text.usetex'] = False
|
||||||
|
|
||||||
import nose
|
import nose
|
||||||
nose.main('GPy', defaultTest='GPy/testing/plotting_tests.py')
|
nose.main('GPy', defaultTest='GPy/testing')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue