On the dask backends, slope(agg, name=None) returns a DataArray whose .name is the dask array's internal graph token (e.g. _trim-<hash> for planar, getitem-<hash> for geodesic) instead of None. The numpy and cupy backends correctly return None.
The cause: when name=None is passed to xr.DataArray(dask_array, name=None, ...), xarray adopts the dask array's name rather than leaving it unset. So the public .name ends up backend-dependent and non-deterministic per call.
This is the same class of bug already fixed for zonal (#2611), focal (#2733), and proximity (#2723).
Reproduce
import numpy as np, xarray as xr, dask.array as da
from xrspatial import slope
arr = xr.DataArray(da.from_array(np.random.rand(8, 8), chunks=4),
dims=['y', 'x'],
coords={'y': np.arange(8), 'x': np.arange(8)})
print(slope(arr).name) # -> '_trim-...' ; expected: None
Fix
Reset result.name after construction so all four backends agree (None when name=None, the given name otherwise). Regression tests assert name consistency across numpy/cupy/dask+numpy/dask+cupy for both planar and geodesic methods.
Found by a metadata sweep of the slope module.
On the dask backends,
slope(agg, name=None)returns a DataArray whose.nameis the dask array's internal graph token (e.g._trim-<hash>for planar,getitem-<hash>for geodesic) instead ofNone. The numpy and cupy backends correctly returnNone.The cause: when
name=Noneis passed toxr.DataArray(dask_array, name=None, ...), xarray adopts the dask array's name rather than leaving it unset. So the public.nameends up backend-dependent and non-deterministic per call.This is the same class of bug already fixed for zonal (#2611), focal (#2733), and proximity (#2723).
Reproduce
Fix
Reset
result.nameafter construction so all four backends agree (Nonewhenname=None, the given name otherwise). Regression tests assert name consistency across numpy/cupy/dask+numpy/dask+cupy for both planar and geodesic methods.Found by a metadata sweep of the slope module.