From 69930ee6b19c89dbe1ec2faa0f83ea86dd637aa6 Mon Sep 17 00:00:00 2001
From: Philipp Rudiger
Date: Sun, 11 Sep 2016 14:37:45 +0100
Subject: [PATCH] Created separate bokeh and matplotlib plot instantiation
tests
---
tests/testplotinstantiation.py | 42 +++++++++++++++++++++++++---------
1 file changed, 31 insertions(+), 11 deletions(-)
diff --git a/tests/testplotinstantiation.py b/tests/testplotinstantiation.py
index f71239e12b..af9059b595 100644
--- a/tests/testplotinstantiation.py
+++ b/tests/testplotinstantiation.py
@@ -5,30 +5,36 @@
from unittest import SkipTest
import numpy as np
from holoviews import (Dimension, Curve, Scatter, Overlay, DynamicMap,
- Store, Image, VLine)
+ Store, Image, VLine, NdOverlay, Points)
from holoviews.element.comparison import ComparisonTestCase
+# Standardize backend due to random inconsistencies
try:
- # Standardize backend due to random inconsistencies
from matplotlib import pyplot
pyplot.switch_backend('agg')
from holoviews.plotting.mpl import OverlayPlot
- from holoviews.plotting.comms import JupyterPushComms
- renderer = Store.renderers['matplotlib']
+ from holoviews.plotting.comms import JupyterPushComm
+ mpl_renderer = Store.renderers['matplotlib']
except:
- pyplot = None
+ mpl_renderer = None
+
+try:
+ import holoviews.plotting.bokeh
+ bokeh_renderer = Store.renderers['bokeh']
+except:
+ bokeh_renderer = None
-class TestPlotInstantiation(ComparisonTestCase):
+class TestMPLPlotInstantiation(ComparisonTestCase):
def setUp(self):
- if pyplot is None:
+ if mpl_renderer is None:
raise SkipTest("Matplotlib required to test plot instantiation")
- self.default_comm = renderer.comms['default']
- renderer.comms['default'] = JupyterPushComms
+ self.default_comm, _ = mpl_renderer.comms['default']
+ mpl_renderer.comms['default'] = (JupyterPushComm, '')
def teardown(self):
- renderer.comms['default'] = self.default_comm
+ mpl_renderer.comms['default'] = (self.default_comm, '')
def test_interleaved_overlay(self):
"""
@@ -44,4 +50,18 @@ def test_dynamic_nonoverlap(self):
dmap1 = DynamicMap(lambda x, y, z: Image(np.random.rand(10,10)), kdims=kdims)
dmap2 = DynamicMap(lambda x: Curve(np.random.rand(10,2))*VLine(x),
kdims=kdims[:1])
- renderer.get_widget(dmap1 + dmap2, 'selection')
+ mpl_renderer.get_widget(dmap1 + dmap2, 'selection')
+
+
+
+class TestBokehPlotInstantiation(ComparisonTestCase):
+
+ def setUp(self):
+ if not bokeh_renderer:
+ raise SkipTest("Bokeh required to test plot instantiation")
+
+ def test_batched_plot(self):
+ overlay = NdOverlay({i: Points(np.arange(i)) for i in range(1, 100)})
+ plot = bokeh_renderer.get_plot(overlay)
+ extents = plot.get_extents(overlay, {})
+ self.assertEqual(extents, (0, 0, 98, 98))