Skip to content

Commit

Permalink
Validate dimensionality of xarray interface data (#5140)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Nov 17, 2021
1 parent c9c4bc3 commit 4ea310a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions holoviews/core/data/xarray.py
Expand Up @@ -207,6 +207,26 @@ def retrieve_unit_and_label(dim):
"for all defined kdims, %s coordinates not found."
% not_found, cls)

for vdim in vdims:
if packed:
continue
da = data[vdim.name]
# Do not enforce validation for irregular arrays since they
# not need to be canonicalized
if any(len(da.coords[c].shape) > 1 for c in da.coords):
continue
undeclared = [
c for c in da.coords if c not in kdims and len(da[c].shape) == 1 and
da[c].shape[0] > 1]
if undeclared:
raise DataError(
'The coordinates on the %r DataArray do not match the '
'provided key dimensions (kdims). The following coords '
'were left unspecified: %r. If you are requesting a '
'lower dimensional view such as a histogram cast '
'the xarray to a columnar format using the .to_dataframe '
'or .to_dask_dataframe methods before providing it to '
'HoloViews.' % (vdim.name, undeclared))
return data, {'kdims': kdims, 'vdims': vdims}, {}


Expand Down

0 comments on commit 4ea310a

Please sign in to comment.