Skip to content

Commit

Permalink
fix calling special plotting methods with the hvplot backend
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt committed Feb 5, 2025
1 parent d2bce93 commit 6deb058
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions hvplot/tests/testplotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@

no_args = ['line', 'area', 'hist', 'box', 'kde', 'density', 'bar', 'barh']
x_y = ['scatter', 'hexbin']
frame_specials = [
# delegates to boxplot_frame
('boxplot', hv.BoxWhisker),
# delegates to hist_frame
('hist', hv.Histogram),
]
series_specials = [
# delegates to hist_series
('hist', hv.Histogram)
]

no_args_mapping = [
(kind, el) for kind, el in HoloViewsConverter._kind_mapping.items() if kind in no_args
Expand Down Expand Up @@ -50,6 +60,18 @@ def test_pandas_dataframe_plot_does_not_implement_pie(self):
with self.assertRaisesRegex(NotImplementedError, 'pie'):
df.plot.pie(y='a')

@parameterized.expand(series_specials)
def test_pandas_series_specials_plot_return_holoviews_object(self, kind, el):
series = pd.Series([0, 1, 2])
plot = getattr(series, kind)()
self.assertIsInstance(plot, el)

@parameterized.expand(frame_specials)
def test_pandas_frame_specials_plot_return_holoviews_object(self, kind, el):
df = pd.DataFrame([0, 1, 2])
plot = getattr(df, kind)()
self.assertIsInstance(plot, el)


class TestPandasHvplotPlotting(TestPandasHoloviewsPlotting):
def setUp(self):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies = [

[project.entry-points."pandas_plotting_backends"]
holoviews = "hvplot:plotting"
hvplot = "hvplot:plotting"

[project.urls]
Homepage = "https://hvplot.holoviz.org"
Expand Down

0 comments on commit 6deb058

Please sign in to comment.