You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a the reverse problem of #6379, the DataArrayGroupBy._combine method seems broken when the mapped function returns a Dataset (which worked before #5692).
---------------------------------------------------------------------------TypeErrorTraceback (mostrecentcalllast)
InputIn [3], in<module>---->1ds.air.resample(time="YS").map(lambdagrp: grp.mean("time").to_dataset())
File~/Python/myxarray/xarray/core/resample.py:223, inDataArrayResample.map(self, func, shortcut, args, **kwargs)
180"""Apply a function to each array in the group and concatenate them 181 together into a new array. 182 (...) 219 The result of splitting, applying and combining this array. 220 """221# TODO: the argument order for Resample doesn't match that for its parent,222# GroupBy-->223combined=super().map(func, shortcut=shortcut, args=args, **kwargs)
225# If the aggregation function didn't drop the original resampling226# dimension, then we need to do so before we can rename the proxy227# dimension we used.228ifself._dimincombined.coords:
File~/Python/myxarray/xarray/core/groupby.py:835, inDataArrayGroupByBase.map(self, func, shortcut, args, **kwargs)
833grouped=self._iter_grouped_shortcut() ifshortcutelseself._iter_grouped()
834applied= (maybe_wrap_array(arr, func(arr, *args, **kwargs)) forarringrouped)
-->835returnself._combine(applied, shortcut=shortcut)
File~/Python/myxarray/xarray/core/groupby.py:869, inDataArrayGroupByBase._combine(self, applied, shortcut)
867index, index_vars=create_default_index_implicit(coord)
868indexes= {k: indexforkinindex_vars}
-->869combined=combined._overwrite_indexes(indexes, coords=index_vars)
870combined=self._maybe_restore_empty_groups(combined)
871combined=self._maybe_unstack(combined)
TypeError: _overwrite_indexes() gotanunexpectedkeywordargument'coords'
Ah yes, good catch @aulemahal. I'd be surprised if such example of returning a Dataset from DataArray groups is a common case, but since it seems to work well there no reason not to support it?
What happened?
This is a the reverse problem of #6379, the
DataArrayGroupBy._combine
method seems broken when the mapped function returns a Dataset (which worked before #5692).What did you expect to happen?
No response
Minimal Complete Verifiable Example
Relevant log output
Anything else we need to know?
I guess the same solution as #6386 could be used!
Environment
INSTALLED VERSIONS
commit: None
python: 3.9.6 | packaged by conda-forge | (default, Jul 11 2021, 03:39:48)
[GCC 9.3.0]
python-bits: 64
OS: Linux
OS-release: 5.16.13-arch1-1
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: fr_CA.utf8
LOCALE: ('fr_CA', 'UTF-8')
libhdf5: 1.12.0
libnetcdf: 4.7.4
xarray: 2022.3.1.dev16+g3ead17ea
pandas: 1.4.0
numpy: 1.20.3
scipy: 1.7.1
netCDF4: 1.5.7
pydap: None
h5netcdf: 0.11.0
h5py: 3.4.0
Nio: None
zarr: 2.10.0
cftime: 1.5.0
nc_time_axis: 1.3.1
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.3.2
dask: 2021.08.0
distributed: 2021.08.0
matplotlib: 3.4.3
cartopy: None
seaborn: None
numbagg: None
fsspec: 2021.07.0
cupy: None
pint: 0.18
sparse: None
setuptools: 57.4.0
pip: 21.2.4
conda: None
pytest: 6.2.5
IPython: 8.0.1
sphinx: 4.1.2
The text was updated successfully, but these errors were encountered: