Repository navigation
Document that .item() is not implemented for lazy arrays (#7916) - #11659
Merged
Merged
Conversation
Improve the NotImplementedError raised for methods that do not work on dask arrays (e.g. .item()) to suggest loading the data into memory first, and add a note to the DataArray.item / Variable.item docstring pointing to .compute().item() / .as_numpy().item(). Co-authored-by: Claude <noreply@anthropic.com>
headtr1ck
reviewed
Oct 4, 2026
headtr1ck
left a comment
Collaborator
There was a problem hiding this comment.
There is already a "Notes" section. I guess we should move the extra note into there?
4 tasks done
dcherian
approved these changes
Oct 24, 2026
dcherian
enabled auto-merge (squash)
October 24, 2026 15:10
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.
.item()on a lazy (dask-backed)DataArray/Variablecurrently raises ageneric
NotImplementedErrorwith no hint about how to proceed (#7916).Per the discussion in #7916, the agreed resolution is not to implicitly
compute, but to document the limitation and make the error actionable. This PR:
NotImplementedErrorraised for methods that don't work on daskarrays (
fail_on_dask_array_input) to suggest loading the data into memoryfirst, e.g. with
.compute()or.load();DataArray.item/Variable.itemdocstring pointing to.compute().item()/.as_numpy().item()(as suggested by @dcherian and@slevang in the thread);
whats-new.rstentry.No behaviour change — eager
.item()works exactly as before; only the errormessage text and docstring change.
Checklist
whats-new.rstapi.rstAI Disclosure
Tools: Claude Code (Claude Opus 4.8). Prompt: implement the maintainer-agreed
resolution of .item() breaks on dataarray if dask arrays are (implicitely) used #7916 — document that
.item()is not implemented for lazy(dask) arrays and make the raised error message suggest loading into memory
first; keep it docs/message-only with no behaviour change.