Description
xrspatial.zonal.apply() returns a DataArray but never sets the result's .name, so the value of .name depends on which backend ran:
- numpy and cupy:
.name is None
- dask+numpy and dask+cupy:
.name is an internal dask task name such as _chunk_fn-3e337fb640ced2398a1cced35ab359af
The dask name is a graph-task hash, so it is non-deterministic between runs too.
Every other DataArray-returning function in zonal.py sets a deterministic name and exposes a name= parameter: regions -> 'regions', hypsometric_integral -> 'hypsometric_integral', trim -> 'trim', crop -> 'crop'. apply() is the odd one out.
A pipeline that chains apply(...) into .to_dataset(), or otherwise relies on .name, gets a different (and on dask, meaningless) result depending on the backend.
Expected behavior
apply() should set a stable .name on its output and accept a name parameter, matching the rest of the zonal functions.
Proposed fix
Add a name parameter to apply() (default None) and pass it to the returned xr.DataArray. This makes .name deterministic and identical across all four backends.
Backends affected
numpy, cupy, dask+numpy, dask+cupy.
Description
xrspatial.zonal.apply()returns a DataArray but never sets the result's.name, so the value of.namedepends on which backend ran:.nameisNone.nameis an internal dask task name such as_chunk_fn-3e337fb640ced2398a1cced35ab359afThe dask name is a graph-task hash, so it is non-deterministic between runs too.
Every other DataArray-returning function in
zonal.pysets a deterministic name and exposes aname=parameter:regions->'regions',hypsometric_integral->'hypsometric_integral',trim->'trim',crop->'crop'.apply()is the odd one out.A pipeline that chains
apply(...)into.to_dataset(), or otherwise relies on.name, gets a different (and on dask, meaningless) result depending on the backend.Expected behavior
apply()should set a stable.nameon its output and accept anameparameter, matching the rest of the zonal functions.Proposed fix
Add a
nameparameter toapply()(defaultNone) and pass it to the returnedxr.DataArray. This makes.namedeterministic and identical across all four backends.Backends affected
numpy, cupy, dask+numpy, dask+cupy.