Skip to content

Commit

Permalink
Fixed bugs introduced by irregular data handling
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Nov 30, 2017
1 parent 2899a88 commit 9270153
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion holoviews/core/data/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def ndloc(cls, dataset, indices):
selected[kd.name] = coords
all_scalar = False
for d in dataset.dimensions():
if d in dataset.kdims and cls.irregular(dataset, d):
if d in dataset.kdims and not cls.irregular(dataset, d):
continue
arr = dataset.dimension_values(d, flat=False)
if all_scalar and len(dataset.vdims) == 1:
Expand Down
6 changes: 6 additions & 0 deletions holoviews/core/data/iris.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ def validate(cls, dataset, vdims=True):
raise DataError("Iris cubes do not support more than one value dimension", cls)


@classmethod
def irregular(cls, dataset, dim):
"CubeInterface does not support irregular data"
return False


@classmethod
def shape(cls, dataset, gridded=False):
if gridded:
Expand Down
12 changes: 6 additions & 6 deletions holoviews/core/data/xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def coords(cls, dataset, dim, ordered=False, expanded=False, edges=False):
def values(cls, dataset, dim, expanded=True, flat=True):
dim = dataset.get_dimension(dim, strict=True)
data = dataset.data[dim.name].data
irregular = cls.irregular(dataset, dim)
irregular = cls.irregular(dataset, dim) if dim in dataset.kdims else False
if dim in dataset.vdims or irregular:
coord_dims = list(dataset.data[dim.name].dims)
if dask and isinstance(data, dask.array.Array):
Expand Down Expand Up @@ -226,18 +226,18 @@ def unpack_scalar(cls, dataset, data):

@classmethod
def ndloc(cls, dataset, indices):
kdims = [d.name for d in dataset.kdims[::-1]]
kdims = [d for d in dataset.kdims[::-1]]
adjusted_indices = []
slice_dims = []
for kd, ind in zip(kdims, indices):
if dataset.data[kd].ndim > 1:
if cls.irregular(dataset, kd):
coords = [c for c in dataset.data.coords if c not in dataset.data.dims]
dim = dataset.data[kd].dims[coords.index(kd)]
shape = dataset.data[kd].shape[coords.index(kd)]
dim = dataset.data[kd.name].dims[coords.index(kd.name)]
shape = dataset.data[kd.name].shape[coords.index(kd.name)]
coords = np.arange(shape)
else:
coords = cls.coords(dataset, kd, False)
dim = kd
dim = kd.name
slice_dims.append(dim)
ncoords = len(coords)
if np.all(coords[1:] < coords[:-1]):
Expand Down

0 comments on commit 9270153

Please sign in to comment.