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

fix(core.data.interface): check if data.interface is a class #5050

Merged
merged 1 commit into from
Jul 30, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion holoviews/core/data/interface.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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