diff --git a/GPy/testing/plotting_tests.py b/GPy/testing/plotting_tests.py
index 563df084..872c84b1 100644
--- a/GPy/testing/plotting_tests.py
+++ b/GPy/testing/plotting_tests.py
@@ -30,15 +30,16 @@
import numpy as np
import GPy, os, sys
from nose import SkipTest
+import unittest
try:
- from matplotlib import cbook
+ from matplotlib import cbook, pyplot as plt
import matplotlib
matplotlib.rcParams['text.usetex'] = False
except:
raise SkipTest("Matplotlib not installed, not testing plots")
-extensions = ['pdf']
+extensions = ['svg', 'pdf']
def _image_directories(func):
"""
@@ -62,13 +63,44 @@ def _image_directories(func):
return baseline_dir, result_dir
-import matplotlib.testing.decorators
-matplotlib.testing.decorators._image_directories = _image_directories
-from matplotlib.testing.decorators import image_comparison
-import matplotlib.pyplot as plt
-@image_comparison(baseline_images=['gp_{}'.format(sub) for sub in ["data", "mean", 'conf', 'density', 'error']], extensions=extensions)
-def testPlot():
+def sequenceEqual(a, b):
+ assert len(a) == len(b), "Sequences not same length"
+ for i, [x, y], in enumerate(zip(a, b)):
+ assert x == y, "element not matching {}".format(i)
+
+def notFound(path):
+ raise IOError('File {} not in baseline')
+
+class test_image_comparison(object):
+ def __init__(self, baseline_images=[], extensions=['pdf','svg','ong']):
+ self.baseline_images = baseline_images
+ self.extensions = extensions
+ self.f = None
+
+ def __call__(self, func):
+ self.baseline_dir, self.result_dir = _image_directories(func)
+ def test_wrap():
+ func()
+ for num, base in zip(plt.get_fignums(), self.baseline_images):
+ for ext in self.extensions:
+ fig = plt.figure(num)
+ fig.axes[0].set_axis_off()
+ fig.set_frameon(False)
+ fig.savefig(os.path.join(self.result_dir, "{}.{}".format(base, ext)), frameon=False)
+ print os.path.join(self.result_dir, "{}.{}".format(base, ext))
+ with open(os.path.join(self.result_dir, "{}.{}".format(base, ext)), 'r') as f:
+ try:
+ with open(os.path.join(self.baseline_dir, "{}.{}".format(base, ext)), 'r') as b:
+ yield sequenceEqual, f.read(), b.read()
+ except:
+ yield notFound, os.path.join(self.baseline_dir, "{}.{}".format(base, ext))
+ #plt.close(num)
+
+ return test_wrap
+
+@test_image_comparison(baseline_images=['gp_{}'.format(sub) for sub in ["data", "mean", 'conf', 'density', 'error']], extensions=extensions)
+def Plot(self=None):
np.random.seed(11111)
X = np.random.uniform(0, 1, (40, 1))
f = .2 * np.sin(1.3*X) + 1.3*np.cos(2*X)
@@ -81,8 +113,8 @@ def testPlot():
m.plot_density()
m.plot_errorbars_trainset()
-@image_comparison(baseline_images=['sparse_gp_{}'.format(sub) for sub in ["data", "mean", 'conf', 'density', 'error', 'inducing']], extensions=extensions)
-def testPlotSparse():
+@test_image_comparison(baseline_images=['sparse_gp_{}'.format(sub) for sub in ["data", "mean", 'conf', 'density', 'error', 'inducing']], extensions=extensions)
+def PlotSparse(self=None):
np.random.seed(11111)
X = np.random.uniform(0, 1, (40, 1))
f = .2 * np.sin(1.3*X) + 1.3*np.cos(2*X)
@@ -96,8 +128,8 @@ def testPlotSparse():
m.plot_errorbars_trainset()
m.plot_inducing()
-@image_comparison(baseline_images=['gp_class_{}'.format(sub) for sub in ["", "raw", 'link', 'raw_link']], extensions=extensions)
-def testPlotClassification():
+@test_image_comparison(baseline_images=['gp_class_{}'.format(sub) for sub in ["", "raw", 'link', 'raw_link']], extensions=extensions)
+def PlotClassification(self=None):
np.random.seed(11111)
X = np.random.uniform(0, 1, (40, 1))
f = .2 * np.sin(1.3*X) + 1.3*np.cos(2*X)
@@ -109,8 +141,8 @@ def testPlotClassification():
m.plot(plot_raw=False, apply_link=True)
m.plot(plot_raw=True, apply_link=True)
-@image_comparison(baseline_images=['sparse_gp_class_{}'.format(sub) for sub in ["", "raw", 'link', 'raw_link']], extensions=extensions)
-def testPlotSparseClassification():
+@test_image_comparison(baseline_images=['sparse_gp_class_{}'.format(sub) for sub in ["", "raw", 'link', 'raw_link']], extensions=extensions)
+def PlotSparseClassification(self=None):
np.random.seed(11111)
X = np.random.uniform(0, 1, (40, 1))
f = .2 * np.sin(1.3*X) + 1.3*np.cos(2*X)
diff --git a/GPy/testing/plotting_tests/baseline/gp_class_.pdf b/GPy/testing/plotting_tests/baseline/gp_class_.pdf
index 1c8fa42c..e3474fcd 100644
Binary files a/GPy/testing/plotting_tests/baseline/gp_class_.pdf and b/GPy/testing/plotting_tests/baseline/gp_class_.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/gp_class_.svg b/GPy/testing/plotting_tests/baseline/gp_class_.svg
new file mode 100644
index 00000000..db77357e
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/gp_class_.svg
@@ -0,0 +1,71 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/gp_class_link.pdf b/GPy/testing/plotting_tests/baseline/gp_class_link.pdf
index 8573deb1..5f09a2d2 100644
Binary files a/GPy/testing/plotting_tests/baseline/gp_class_link.pdf and b/GPy/testing/plotting_tests/baseline/gp_class_link.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/gp_class_link.svg b/GPy/testing/plotting_tests/baseline/gp_class_link.svg
new file mode 100644
index 00000000..d8a56507
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/gp_class_link.svg
@@ -0,0 +1,432 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/gp_class_raw.pdf b/GPy/testing/plotting_tests/baseline/gp_class_raw.pdf
index 34ee9a16..c20f9b20 100644
Binary files a/GPy/testing/plotting_tests/baseline/gp_class_raw.pdf and b/GPy/testing/plotting_tests/baseline/gp_class_raw.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/gp_class_raw.svg b/GPy/testing/plotting_tests/baseline/gp_class_raw.svg
new file mode 100644
index 00000000..27c507a3
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/gp_class_raw.svg
@@ -0,0 +1,60 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/gp_class_raw_link.pdf b/GPy/testing/plotting_tests/baseline/gp_class_raw_link.pdf
index ea1914c3..7fbd6d07 100644
Binary files a/GPy/testing/plotting_tests/baseline/gp_class_raw_link.pdf and b/GPy/testing/plotting_tests/baseline/gp_class_raw_link.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/gp_class_raw_link.svg b/GPy/testing/plotting_tests/baseline/gp_class_raw_link.svg
new file mode 100644
index 00000000..972f18a4
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/gp_class_raw_link.svg
@@ -0,0 +1,27967 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/gp_conf.pdf b/GPy/testing/plotting_tests/baseline/gp_conf.pdf
index 00db6557..92bb222d 100644
Binary files a/GPy/testing/plotting_tests/baseline/gp_conf.pdf and b/GPy/testing/plotting_tests/baseline/gp_conf.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/gp_conf.svg b/GPy/testing/plotting_tests/baseline/gp_conf.svg
new file mode 100644
index 00000000..d8a56507
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/gp_conf.svg
@@ -0,0 +1,432 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/gp_data.pdf b/GPy/testing/plotting_tests/baseline/gp_data.pdf
index 43d4aeb0..c4ec5ca7 100644
Binary files a/GPy/testing/plotting_tests/baseline/gp_data.pdf and b/GPy/testing/plotting_tests/baseline/gp_data.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/gp_data.svg b/GPy/testing/plotting_tests/baseline/gp_data.svg
new file mode 100644
index 00000000..db77357e
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/gp_data.svg
@@ -0,0 +1,71 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/gp_density.pdf b/GPy/testing/plotting_tests/baseline/gp_density.pdf
index 7e6b2bc7..aa1ecafa 100644
Binary files a/GPy/testing/plotting_tests/baseline/gp_density.pdf and b/GPy/testing/plotting_tests/baseline/gp_density.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/gp_density.svg b/GPy/testing/plotting_tests/baseline/gp_density.svg
new file mode 100644
index 00000000..972f18a4
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/gp_density.svg
@@ -0,0 +1,27967 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/gp_error.pdf b/GPy/testing/plotting_tests/baseline/gp_error.pdf
index 46e3397e..7ef9298c 100644
Binary files a/GPy/testing/plotting_tests/baseline/gp_error.pdf and b/GPy/testing/plotting_tests/baseline/gp_error.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/gp_error.svg b/GPy/testing/plotting_tests/baseline/gp_error.svg
new file mode 100644
index 00000000..25cc730d
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/gp_error.svg
@@ -0,0 +1,235 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/gp_mean.pdf b/GPy/testing/plotting_tests/baseline/gp_mean.pdf
index 0e77518a..10d650f7 100644
Binary files a/GPy/testing/plotting_tests/baseline/gp_mean.pdf and b/GPy/testing/plotting_tests/baseline/gp_mean.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/gp_mean.svg b/GPy/testing/plotting_tests/baseline/gp_mean.svg
new file mode 100644
index 00000000..27c507a3
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/gp_mean.svg
@@ -0,0 +1,60 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_class_.pdf b/GPy/testing/plotting_tests/baseline/sparse_gp_class_.pdf
index 064e3e92..1503cdb8 100644
Binary files a/GPy/testing/plotting_tests/baseline/sparse_gp_class_.pdf and b/GPy/testing/plotting_tests/baseline/sparse_gp_class_.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_class_.svg b/GPy/testing/plotting_tests/baseline/sparse_gp_class_.svg
new file mode 100644
index 00000000..db77357e
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/sparse_gp_class_.svg
@@ -0,0 +1,71 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_class_link.pdf b/GPy/testing/plotting_tests/baseline/sparse_gp_class_link.pdf
index 064e3e92..90cfdd9e 100644
Binary files a/GPy/testing/plotting_tests/baseline/sparse_gp_class_link.pdf and b/GPy/testing/plotting_tests/baseline/sparse_gp_class_link.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_class_link.svg b/GPy/testing/plotting_tests/baseline/sparse_gp_class_link.svg
new file mode 100644
index 00000000..d8a56507
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/sparse_gp_class_link.svg
@@ -0,0 +1,432 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw.pdf b/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw.pdf
index 46753a26..9fcc176b 100644
Binary files a/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw.pdf and b/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw.svg b/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw.svg
new file mode 100644
index 00000000..27c507a3
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw.svg
@@ -0,0 +1,60 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw_link.pdf b/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw_link.pdf
index 8b0ac8c7..17ea5d1a 100644
Binary files a/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw_link.pdf and b/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw_link.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw_link.svg b/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw_link.svg
new file mode 100644
index 00000000..972f18a4
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/sparse_gp_class_raw_link.svg
@@ -0,0 +1,27967 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_conf.pdf b/GPy/testing/plotting_tests/baseline/sparse_gp_conf.pdf
index 9735b121..ad0d027d 100644
Binary files a/GPy/testing/plotting_tests/baseline/sparse_gp_conf.pdf and b/GPy/testing/plotting_tests/baseline/sparse_gp_conf.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_conf.svg b/GPy/testing/plotting_tests/baseline/sparse_gp_conf.svg
new file mode 100644
index 00000000..d8a56507
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/sparse_gp_conf.svg
@@ -0,0 +1,432 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_data.pdf b/GPy/testing/plotting_tests/baseline/sparse_gp_data.pdf
index 349fc871..34f01b09 100644
Binary files a/GPy/testing/plotting_tests/baseline/sparse_gp_data.pdf and b/GPy/testing/plotting_tests/baseline/sparse_gp_data.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_data.svg b/GPy/testing/plotting_tests/baseline/sparse_gp_data.svg
new file mode 100644
index 00000000..db77357e
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/sparse_gp_data.svg
@@ -0,0 +1,71 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_density.pdf b/GPy/testing/plotting_tests/baseline/sparse_gp_density.pdf
index 2594946c..a028b3c9 100644
Binary files a/GPy/testing/plotting_tests/baseline/sparse_gp_density.pdf and b/GPy/testing/plotting_tests/baseline/sparse_gp_density.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_density.svg b/GPy/testing/plotting_tests/baseline/sparse_gp_density.svg
new file mode 100644
index 00000000..972f18a4
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/sparse_gp_density.svg
@@ -0,0 +1,27967 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_error.pdf b/GPy/testing/plotting_tests/baseline/sparse_gp_error.pdf
index aadd771e..596cf2be 100644
Binary files a/GPy/testing/plotting_tests/baseline/sparse_gp_error.pdf and b/GPy/testing/plotting_tests/baseline/sparse_gp_error.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_error.svg b/GPy/testing/plotting_tests/baseline/sparse_gp_error.svg
new file mode 100644
index 00000000..25cc730d
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/sparse_gp_error.svg
@@ -0,0 +1,235 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_inducing.pdf b/GPy/testing/plotting_tests/baseline/sparse_gp_inducing.pdf
index b856598e..f6e3b1cf 100644
Binary files a/GPy/testing/plotting_tests/baseline/sparse_gp_inducing.pdf and b/GPy/testing/plotting_tests/baseline/sparse_gp_inducing.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_inducing.svg b/GPy/testing/plotting_tests/baseline/sparse_gp_inducing.svg
new file mode 100644
index 00000000..129c4454
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/sparse_gp_inducing.svg
@@ -0,0 +1,552 @@
+
+
+
+
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_mean.pdf b/GPy/testing/plotting_tests/baseline/sparse_gp_mean.pdf
index 957321f5..c37424c1 100644
Binary files a/GPy/testing/plotting_tests/baseline/sparse_gp_mean.pdf and b/GPy/testing/plotting_tests/baseline/sparse_gp_mean.pdf differ
diff --git a/GPy/testing/plotting_tests/baseline/sparse_gp_mean.svg b/GPy/testing/plotting_tests/baseline/sparse_gp_mean.svg
new file mode 100644
index 00000000..27c507a3
--- /dev/null
+++ b/GPy/testing/plotting_tests/baseline/sparse_gp_mean.svg
@@ -0,0 +1,60 @@
+
+
+
+