Skip to content

Commit

Permalink
fix(core.data.interface): check if data.interface is a class before c…
Browse files Browse the repository at this point in the history
…alling issubclass (#5050)

Fixes holoviz/hvplot#645

Co-authored-by: Geronimo Bergk <geronimo.bergk@hhi.fraunhofer.de>
  • Loading branch information
geronimos and Geronimo Bergk committed Jul 30, 2021
1 parent d5a3f41 commit 7dadbcb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion holoviews/core/data/interface.py
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions holoviews/tests/core/data/test_pandasinterface.py
Expand Up @@ -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):
Expand Down

0 comments on commit 7dadbcb

Please sign in to comment.