From 7dadbcb7729ac30de112adb2d1661adf8749beed Mon Sep 17 00:00:00 2001 From: Geronimo Bergk Date: Fri, 30 Jul 2021 17:23:14 +0200 Subject: [PATCH] fix(core.data.interface): check if data.interface is a class before calling issubclass (#5050) Fixes https://github.com/holoviz/hvplot/issues/645 Co-authored-by: Geronimo Bergk --- holoviews/core/data/interface.py | 2 +- holoviews/tests/core/data/test_pandasinterface.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/holoviews/core/data/interface.py b/holoviews/core/data/interface.py index 82a366125b..ac3d62e7aa 100644 --- a/holoviews/core/data/interface.py +++ b/holoviews/core/data/interface.py @@ -203,7 +203,7 @@ def initialize(cls, eltype, data, kdims, vdims, datatype=None): vdims = pvals.get('vdims') if vdims is None else vdims # Process Element data - if (hasattr(data, 'interface') and issubclass(data.interface, Interface)): + if hasattr(data, 'interface') and isinstance(data.interface, type) and issubclass(data.interface, Interface): if datatype is None: datatype = [dt for dt in data.datatype if dt in eltype.datatype] if not datatype: diff --git a/holoviews/tests/core/data/test_pandasinterface.py b/holoviews/tests/core/data/test_pandasinterface.py index 6dcaa74763..5812fd99ab 100644 --- a/holoviews/tests/core/data/test_pandasinterface.py +++ b/holoviews/tests/core/data/test_pandasinterface.py @@ -165,6 +165,10 @@ def test_dataset_from_multi_index_tuple_dims(self): ds = Dataset(df.groupby(['x', 'y']).mean(), [('x', 'X'), ('y', 'Y')]) self.assertEqual(ds, Dataset(df, [('x', 'X'), ('y', 'Y')])) + def test_dataset_with_interface_column(self): + df = pd.DataFrame([1], columns=['interface']) + ds = Dataset(df) + self.assertEqual(list(ds.data.columns), ['interface']) class PandasInterfaceTests(BasePandasInterfaceTests):