focal: pin result .name across backends in focal_stats and hotspots#2735
Open
brendancol wants to merge 1 commit into
Open
focal: pin result .name across backends in focal_stats and hotspots#2735brendancol wants to merge 1 commit into
brendancol wants to merge 1 commit into
Conversation
The dask paths of focal_stats and hotspots built the output DataArray without an explicit name=, so xarray adopted the dask array's internal graph token (_trim-<hash>) as the public .name. That made .name differ across the four backends and leaked a non-deterministic implementation detail. focal_stats now sets result.name='focal_apply' (the name the numpy path already emits); hotspots passes name='hotspots'. Adds parametrized name-consistency tests for both functions across all four backends. Fixes #2733
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
focal_statsandhotspotsreturned a DataArray whose.namediffered across the four backends. On the dask paths the name was a non-deterministic dask graph token (_trim-<hash>).focal_applyNonefocal_apply_trim-<hash>NoneNone_trim-<hash>_trim-<hash>Why
The dask code paths build the output
xr.DataArraywithout an explicitname=. When the backing array is a dask array, xarray adopts the dask array's internal graph-layer name as the public.name..nameis user-visible metadata: it shows in the repr, becomes the variable key into_dataset(), and sets default plot labels. A chained pipeline got a different name depending on which backend ran. Same class as the zonal.apply fix (#2611).Fix
focal_stats: setresult.name = 'focal_apply'after construction (the name the numpy/dask+numpy paths already emit). Assigning at the dask DataArray constructor does not override the graph name, so this is done post-construction.hotspots: passname='hotspots'.The rest of the metadata (attrs
res/crs/nodatavals, coords, dims) was already preserved consistently across all four backends.Tests
Two parametrized regression tests assert name consistency for
focal_statsandhotspotsacross numpy / dask+numpy / cupy / dask+cupy. Full focal suite: 122 passed (CUDA host, all backends live).Fixes #2733