Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 committed Oct 3, 2024
1 parent dadec84 commit ea1d123
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,11 @@ def method_wrapper(ds, x, y):

# a workaround to show hover info for datashaded points
if self.hover and self.datashade and self.kind == 'points':
if self.hover_mode != 'mouse':
param.main.param.warning(
f'Got unsupported hover_mode={self.hover_mode!r} for '
f"datashaded points; reverting to 'mouse'."
)
inspector = inspect_points.instance(
streams=[PointerXY], transform=self._datashade_hover_transform
)
Expand Down
19 changes: 18 additions & 1 deletion hvplot/tests/testoperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pandas as pd
import pytest

from holoviews import Store, render
from holoviews import Store, render, renderer
from holoviews.element import Image, QuadMesh, Points
from holoviews.core.spaces import DynamicMap
from holoviews.core.overlay import Overlay
Expand Down Expand Up @@ -324,6 +324,23 @@ def test_downsample_resample_when(self, kind, eltype):
assert isinstance(element, eltype)
assert len(element) == 0

@parameterized.expand([(None,), (True,), ('vline',), ('hline',)])
def test_include_inspect_point_hover(self, hover):
df = pd.DataFrame(
np.random.multivariate_normal((0, 0), [[0.1, 0.1], [0.1, 1.0]], (5000,))
).rename({0: 'x', 1: 'y'}, axis=1)

p = df.hvplot.points(datashade=True, hover=hover)
assert renderer('bokeh').get_plot(p).name.startswith('Overlay')

def test_include_inspect_point_no_hover(self):
df = pd.DataFrame(
np.random.multivariate_normal((0, 0), [[0.1, 0.1], [0.1, 1.0]], (5000,))
).rename({0: 'x', 1: 'y'}, axis=1)

p = df.hvplot.points(datashade=True, hover=False)
assert renderer('bokeh').get_plot(p).name.startswith('RGB')


class TestChart2D(ComparisonTestCase):
def setUp(self):
Expand Down

0 comments on commit ea1d123

Please sign in to comment.