Skip to content

Commit

Permalink
Move irregular to xarray interface
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Feb 27, 2024
1 parent 5f59140 commit 348f6c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions holoviews/core/data/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def concat_dim(cls, datasets, dim, vdims):
def irregular(cls, dataset, dim):
return dataset.data[dimension_name(dim)].ndim > 1


@classmethod
def isscalar(cls, dataset, dim):
values = cls.values(dataset, dim, expanded=False)
Expand Down
9 changes: 7 additions & 2 deletions holoviews/core/data/xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ def validate(cls, dataset, vdims=True):
"following kdims were found to have "
"non-matching array dimensions:\n\n%s"
% ('\n'.join(nonmatching)), cls)
@classmethod
def irregular(cls, dataset, dim):
if dataset.data[dimension_name(dim)].ndim > 1:
return True
dim_name = dimension_name(dim)
return dim_name not in dataset.data.dims and dim_name in dataset.data.coords

@classmethod
def compute(cls, dataset):
Expand Down Expand Up @@ -410,8 +416,7 @@ def values(cls, dataset, dim, expanded=True, flat=True, compute=True, keep_index
data = data.data
irregular = cls.irregular(dataset, dim) if dim in dataset.kdims else False
irregular_kdims = [d for d in dataset.kdims if cls.irregular(dataset, d)]
non_dimensinal_dim = hasattr(dataset.data, 'dims') and dimension_name(dim) not in dataset.data.dims
if irregular_kdims or non_dimensinal_dim:
if irregular_kdims:
virtual_coords = list(dataset.data[irregular_kdims[0].name].coords.dims)
else:
virtual_coords = []
Expand Down

0 comments on commit 348f6c6

Please sign in to comment.