From b06c4f928238cd66373cf984dde86818b55ad890 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Thu, 19 Sep 2019 11:33:45 +0200 Subject: [PATCH 1/3] Replace xarray isel_points with isel --- holoviews/core/data/xarray.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/holoviews/core/data/xarray.py b/holoviews/core/data/xarray.py index b2f25a070c..46884ce765 100644 --- a/holoviews/core/data/xarray.py +++ b/holoviews/core/data/xarray.py @@ -390,8 +390,10 @@ def ndloc(cls, dataset, indices): sampled = (all(isinstance(ind, np.ndarray) and ind.dtype.kind != 'b' for ind in adjusted_indices) and len(indices) == len(kdims)) if sampled or (all_scalar and len(indices) == len(kdims)): + import xarray as xr if all_scalar: isel = {k: [v] for k, v in isel.items()} - return dataset.data.isel_points(**isel).to_dataframe().reset_index() + selected = dataset.data.isel({k: xr.DataArray(v) for k, v in isel.items()}) + return selected.to_dataframe().reset_index() else: return dataset.data.isel(**isel) From 81979fb18af396a373ec1ab718f2040d9a96edda Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Fri, 20 Sep 2019 10:59:20 +0200 Subject: [PATCH 2/3] Handle change in min/max computation in xarray --- holoviews/core/data/xarray.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/holoviews/core/data/xarray.py b/holoviews/core/data/xarray.py index 46884ce765..f2ebb1025b 100644 --- a/holoviews/core/data/xarray.py +++ b/holoviews/core/data/xarray.py @@ -218,6 +218,10 @@ def range(cls, dataset, dimension): da = dask_array_module() if da and isinstance(dmin, da.Array): dmin, dmax = da.compute(dmin, dmax) + if isinstance(dmin, np.ndarray) and dmin.shape == (): + dmin = dmin[()] + if isinstance(dmax, np.ndarray) and dmax.shape == (): + dmax = dmax[()] dmin = dmin if np.isscalar(dmin) or isinstance(dmin, util.datetime_types) else dmin.item() dmax = dmax if np.isscalar(dmax) or isinstance(dmax, util.datetime_types) else dmax.item() return dmin, dmax From a4dbb0cf3222674a8eedd66d311a3bcdd581e23f Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Fri, 20 Sep 2019 11:00:36 +0200 Subject: [PATCH 3/3] Improved handling for xarray transpose --- holoviews/core/data/xarray.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/holoviews/core/data/xarray.py b/holoviews/core/data/xarray.py index f2ebb1025b..51e6cda8c7 100644 --- a/holoviews/core/data/xarray.py +++ b/holoviews/core/data/xarray.py @@ -50,10 +50,11 @@ def shape(cls, dataset, gridded=False): if kd.name in array.dims][::-1] if not all(d in names for d in array.dims): array = np.squeeze(array) - try: - array = array.transpose(*names, transpose_coords=False) - except: - array = array.transpose(*names) # Handle old xarray + if len(names) > 1: + try: + array = array.transpose(*names, transpose_coords=False) + except: + array = array.transpose(*names) # Handle old xarray shape = array.shape if gridded: return shape