-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
No attribute map_over_subtree
#9710
Comments
additionally, Given that Edit: or rather, where in the documentation did you find |
@melonora @keewis There is no mention of @melonora To get you working until #9693 is sorted out, here is a workaround (please also take @keewis comment on transpose arguments into account): import functools
def skip_nodes(func):
@functools.wraps(func)
def _func(ds, *args, **kwargs):
# check if needed dimensions are available in the Dataset
# otherwise return verbatim
if not all(arg in ds.dims for arg in args):
return ds
return func(ds, *args, **kwargs)
return _func
@skip_nodes
def transpose(ds, *args, **kwargs):
return ds.transpose(*args, **kwargs)
multiscale_image = multiscale_image.map_over_datasets(transpose, 'y', 'x', 'c') |
I'll close this as dupe of #9693. |
ah sorry was looking at the xarray_datatree documentation |
Thanks! I had a similar workaround for now |
Hello, I am currently migrating to What is the suggested migration process to migrate such code to the Thanks for your answer |
Sorry apparently I forgot to add this to the migration guide (I've added it in #9804).
Yes, we decided that it was better to have it be consistent with |
What happened?
Looking for a way to map a function over
Datasets
in aDataTree
I was hit by the issue described in #9693. This because of the node with path.
not containing the dimensions I was trying to transpose.Trying to find a workaround with
map_over_subtree
did not work either as seemingly in the latest xarray (2024.10.0) this does not exist. I get anAttributeError
, while according to the documentation the method does exist.What did you expect to happen?
I expect as output a datatree in which the datasets have their dimensions transposed.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment
C:\ProgramData\miniforge3\envs\xarray_datatree\Lib\site-packages_distutils_hack_init_.py:31: UserWarning: Setuptools is replacing distutils. Support for replaci
ng an already imported distutils is deprecated. In the future, this condition will fail. Register concerns at https://github.com/pypa/setuptools/issues/new?template=distutils-deprecation.yml
warnings.warn(
INSTALLED VERSIONS
commit: None
python: 3.11.10 | packaged by conda-forge | (main, Oct 16 2024, 01:17:14) [MSC v.1941 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: AMD64 Family 25 Model 97 Stepping 2, AuthenticAMD
byteorder: little
LC_ALL: None
LANG: None
LOCALE: ('English_Netherlands', '1252')
libhdf5: 1.14.2
libnetcdf: None
xarray: 2024.10.0
pandas: 2.2.3
numpy: 1.26.4
scipy: 1.14.1
netCDF4: None
pydap: None
h5netcdf: None
h5py: 3.12.1
zarr: 2.18.3
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: 2024.6.2
distributed: 2024.6.2
matplotlib: 3.9.2
cartopy: None
seaborn: 0.13.2
numbagg: None
fsspec: 2023.6.0
cupy: None
pint: 0.24.3
sparse: None
flox: None
numpy_groupies: None
setuptools: 75.3.0
pip: 24.3.1
conda: None
pytest: 8.3.3
mypy: 1.13.0
IPython: 8.29.0
sphinx: 8.1.3
The text was updated successfully, but these errors were encountered: