Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed python3 bug in GenericOverlayPlot #856

Merged
merged 2 commits into from Sep 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions holoviews/plotting/plot.py
Expand Up @@ -870,8 +870,8 @@ def _create_subplots(self, ranges):
def get_extents(self, overlay, ranges):
extents = []
items = overlay.items()
if self.batched:
subplot = self.subplots.values()[0]
if self.batched and self.subplots:
subplot = list(self.subplots.values())[0]
subplots = [(k, subplot) for k in overlay.data.keys()]
else:
subplots = self.subplots.items()
Expand Down
42 changes: 31 additions & 11 deletions tests/testplotinstantiation.py
Expand Up @@ -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):
"""
Expand All @@ -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))