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

Work with non-gridded xarray dataset #1082

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
9 changes: 6 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
# Run on the full set on schedule, workflow_dispatch and push&tags events, otherwise on a subset.
python-version: ${{ ( github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'push' && github.ref_type == 'tag' ) ) && fromJSON('["3.7", "3.8", "3.9", "3.10", "3.11"]') || fromJSON('["3.7", "3.9", "3.11"]') }}
exclude:
- os: macos-latest
python-version: 3.7
timeout-minutes: 90
defaults:
run:
Expand All @@ -56,11 +59,11 @@ jobs:
conda-update: true
conda-mamba: mamba
id: install
- name: patch fiona/geostack on Python 3.7 / Macos
if: steps.install.outputs.cache-hit != 'true' && contains(matrix.os, 'macos') && matrix.python-version == '3.7'
- name: Add Holoviews branch
run: |
conda activate test-environment
mamba install "fiona=1.8" "gdal=3.3"
conda uninstall holoviews -y --offline --force || echo already uninstalled
pip install "git+https://github.com/holoviz/holoviews.git@xarray_improve"
- name: doit test_unit
run: |
conda activate test-environment
Expand Down
10 changes: 7 additions & 3 deletions hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,9 @@ def _process_data(self, kind, data, x, y, by, groupby, row, col,
raise ValueError("Cannot plot an empty xarray.Dataset object.")
if z is None:
if isinstance(data, xr.Dataset):
z = list(data.data_vars)[0]
z = [k for k in data.data_vars if k not in (x, y)]
if len(z) > 0:
z = z[0]
else:
z = data.name or label or value_label
if gridded and isinstance(data, xr.Dataset) and not isinstance(z, list):
Expand Down Expand Up @@ -1236,7 +1238,9 @@ def method_wrapper(ds, x, y):
elif self.datatype == 'xarray':
import xarray as xr
if isinstance(data, xr.Dataset):
dataset = Dataset(data, self.indexes)
kdims = self.indexes
vdims = [vd for vd in data.data_vars.variables if vd not in kdims]
dataset = Dataset(data, kdims=kdims, vdims=vdims)
else:
name = data.name or self.label or self.value_label
dataset = Dataset(data, self.indexes, name)
Expand Down Expand Up @@ -2241,7 +2245,7 @@ def _geom_plot(self, x=None, y=None, data=None, kind='polygons'):
redim = self._merge_redim({self._color_dim: self._dim_ranges['c']} if self._color_dim else {})
kdims, vdims = self._get_dimensions([x, y], [])
if self.gridded_data:
vdims = Dataset(data).vdims
vdims = [vd for vd in Dataset(data).vdims if vd not in kdims]
element = self._get_element(kind)
cur_opts, compat_opts = self._get_compat_opts(element.name)
for opts_ in [cur_opts, compat_opts]:
Expand Down