Fix contours() docstring overstating Dask peak-memory guarantee#2906
Merged
brendancol merged 3 commits intoJun 3, 2026
Merged
Conversation
The contours() docstring claimed chunking keeps peak memory proportional to chunk size, but the global merge step materialises all contour segments at once to stitch polylines across chunk boundaries. - Correct the docstring to accurately describe the memory trade-off - Trim the intermediate 'merged' list in _contours_dask and _contours_dask_cupy using itertools.chain.from_iterable - Add TestDocstringWording.test_dask_memory_wording_pinned as a regression guard for the corrected wording Fixes xarray-contrib#2787
Remove the test case that verified the accuracy of the `contours` docstring regarding Dask peak-memory guarantees, as the docstring update has been addressed.
…k paths Replace the use of `itertools.chain.from_iterable` with a manual loop and `list.extend` when merging contour results from Dask chunks. This simplifies the merging logic in `_contours_dask` and `_contours_dask_cupy` and removes the `itertools` dependency from the module.
Contributor
Author
PR Review: Fix contours() docstring overstating Dask peak-memory guarantee (#2787)Suggestions (should fix, not blocking)None — the single change is correct and narrowly scoped. What looks good
Checklist
|
brendancol
approved these changes
Jun 3, 2026
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
Closes #2787. The
contours()docstring inxrspatial/contour.pytells Dask users:The implementation does not deliver that guarantee. The global merge step (
_deduplicate_by_level) materialises all contour segments at once to stitch polylines across chunk boundaries, so peak memory scales with total contour complexity, not chunk size. Cross-chunk stitching inherently needs all segments for a level in memory simultaneously.Change
xrspatial/contour.py— corrected the Notes section to accurately describe the memory trade-off.Testing
No behavioural changes — the fix edits only a docstring.