Fix dask rolling bottleneck dtype metadata#11449
Merged
dcherian merged 4 commits intoJul 13, 2026
Merged
Conversation
Derive dask map_overlap metadata from the bottleneck moving function result for numeric rolling inputs instead of using the generic NA-promotion dtype. Preserve the padded dtype for centered integer rolling while carrying the original bool dtype through centered padding so bool reductions no longer declare object metadata. Add bool and integer rolling coverage comparing numpy and dask dtype/value behavior, including dask meta and computed block dtypes. Co-Authored-By: OpenAI Codex <codex@openai.com>
dcherian
reviewed
Jul 13, 2026
dcherian
approved these changes
Jul 13, 2026
Contributor
Author
|
Thanks @dcherian ! |
Remove a C++-style comment that was introduced on the PR branch and caused xarray imports to fail before CI reached tests. Co-Authored-By: OpenAI Codex <codex@openai.com>
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.
Summary
differ from the matching numpy-backed bottleneck result.
float64metadatainstead of
object, matching the actual bottleneck result dtype.object padding, while continuing to infer centered integer metadata from the
padded dtype.
values, result dtype, dask
_meta, computed block dtype, and full computeddtype.
Background
The same rolling reduction can currently report different dtypes depending on
the backend:
On xarray 2025.12 and current main, the numpy-backed result is
float64, whilethe dask-backed result declares
objectmetadata. With legacy dask, this ispartly masked because computed blocks are still
float64under the declaredobjectmeta. Stricter dask backends can faithfully materialize the declaredobjectdtype, surfacing the inconsistency.Diagnosis
xarray/compat/dask_array_ops.py::dask_rolling_wrapperpreviously declared thedask
map_overlapdtype using:For bool input,
maybe_promote(bool)returnsobject. That promotion isappropriate for generic missing-value operations such as padding, filling, and
where, but it is too broad for bottleneck moving-window reductions.Bottleneck accepts bool arrays directly and returns
float64, which alreadyhas room for the
NaNvalues introduced bymin_periods. The dask wrapper wastherefore declaring metadata from generic NA-promotion rules instead of from the
actual moving function result type.
The centered path has one extra wrinkle: xarray pads before calling the dask
rolling wrapper. For centered bool rolling, padding turns the intermediate dask
array into
object, so dtype inference needs to use the original bool dtype.For centered integer rolling, the padded dtype is already the behavior that
matches the numpy-backed path, so that should be preserved.
Implementation
The dask bottleneck wrapper now derives metadata for numeric and boolean inputs
from the moving function's actual NumPy result dtype. Non-numeric inputs keep
the previous
maybe_promotefallback._bottleneck_reducenow passes an explicitinput_dtypeinto the dask wrapper:bool inputs use the original rolling object dtype, while other inputs use the
padded dtype. This fixes centered bool rolling without changing centered
integer behavior.
This change intentionally does not modify
dtypes.maybe_promote. Themaybe_promote(bool) -> objectrule may be worth revisiting separately, butthat function is shared by broader NA-handling paths and should not be changed
as part of this targeted bottleneck metadata fix.
Tests
int8, andint64inputs._meta, a computed block, and the full computed result allagree on dtype.
stdandmedian, where the numpy-backedbottleneck path itself currently errors.
Checklist
whats-new.rstAI Disclosure
I have tested any AI-generated content in my PR.
I take responsibility for any AI-generated content in my PR.
Tools: Codex