Fix dask array attributes being computed on equivalence check #11845
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.45) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 279 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.337
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #11845"
general
weight: 0.35
djhoese
Description
See #11841 for more details. This is my first attempt at trying to resolve that issue, but it seems to be opening a can of worms. Since #10838 dask-backed objects have been getting computed in any
equivalentcheck. While using Claude to create this PR it was shown to go further than I thought and doingDataArray.identicalon a deep-copy of that same DataArray raises an exception (ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()).This PR at the current time of writing is the simplest version of the fix I could come up with. However, it may not be the best solution. I didn't like the
is_chunked_arrayneeding a typing ignore comment so started working towards a more strict split between scalar and array-like comparisons but it brought up some questions that I don't think I should be the one to answer:1. When an array is compared with a non-"pure" array like a
DataArrayorpd.Index, should they be compared by value like they are today and which computes lazy arrays? Or should they be considered not equal.2. Should eager non-numpy duck arrays be compared by value? Today they aren't equal.
3. Should the rule I've been going by that two lazy arrays should not be computed and are only equal if their tokens are equal be the rule? Or are their exceptions?
The biggest complication seems to be things of different types, especially arrays and non-pure arrays, as you can easily end up computing lazy arrays.
Checklist
<!-- Feel free to remove check-list items aren't relevant to your change -->
whats-new.rstAI Disclosure
<!--- Please review our AI & contribution guidelines: https://docs.xarray.dev/en/stable/contribute/ai-policy.html. Remove this section if your PR does not contain AI-generated content. --->
- [x] I have tested any AI-generated content in my PR.
- [x] I take responsibility for any AI-generated content in my PR.
<!--- If you used AI to generate code, please specify the tool used and the prompt below. --->
Tools: Claude (Opus)