Repository navigation
Treat masked values as missing in in-place binary operations - #11955
Open
AsadullahMaliyawala wants to merge 3 commits into
Open
AsadullahMaliyawala wants to merge 3 commits into
AsadullahMaliyawala wants to merge 3 commits into
Conversation
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
headtr1ck
approved these changes
Nov 30, 2026
This branch has not been deployed
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.
Description
#11911 made binary operations with a NumPy masked array treat masked values as missing, but the in-place path (
Variable._inplace_binary_op, also used byDataArray) still passes the raw masked array to the operator. Sincendarray += MaskedArraywrites into the plain ndarray, the mask is silently dropped and the data underneath it is used:This applies the same
as_compatible_dataconversion in_inplace_binary_op. When nothing is masked, the underlying data is used as is, soint_da += np.ma.array([1, 2, 3])keeps working with an integer dtype (as_compatible_dataalways promotes masked integer arrays to float, which can't be cast back in place). An integer array combined in place with a masked array that actually has masked elements now raises numpy's casting error, the same asint_da += np.array([1.0, np.nan]), instead of silently using the masked values.Found while reviewing #11911; it is not released yet, so I added the entry next to its whats-new entry.
Checklist
whats-new.rstAI Disclosure
Tools: Claude Code (Claude Opus 5.5), used to review the recent changes, write the patch and tests, and run the tests locally.