Repository navigation
Conversation
…ctured array `_set_selection` validated `fields` and then dropped it, casting the value to the full structured dtype. Writing `fields="b"` therefore broadcast the value into every field of each selected record. Field writes now read the selected records, replace the named field, and write the whole records back. A tuple naming several fields is rejected like a list. Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
…developers#4503 Assisted-by: ClaudeCode:claude-opus-5-5
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4503 +/- ##
==========================================
+ Coverage 94.71% 94.76% +0.05%
==========================================
Files 94 94
Lines 13663 13668 +5
==========================================
+ Hits 12941 12953 +12
+ Misses 722 715 -7
🚀 New features to boost your workflow:
|
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.
🤖 AI text below 🤖
Writing one field of a structured array (
fields="b") no longer overwrites the other fields of each selected record. Passing a tuple that names several fields to a write now raisesIndexError, as a list already did.On
main,_set_selectionvalidatesfieldsand then drops it, casting the value to the full structured dtype. For example,z.set_basic_selection(slice(None), np.full(10, 7.0), fields="b")sets every field of every record to 7. This happens for v2, v3, and sharded v3 arrays, and for basic, orthogonal, coordinate, mask, and block writes.With this change, a field write reads the selected records into a full-dtype buffer, assigns the field, and writes the whole records back. Missing chunks are read as the fill value even when
read_missing_chunksis false, as they are for any partial chunk write. The cost is one extra read of the selection, and only field writes pay it. Like any partial-chunk write, the read and the write are not atomic.Tests:
test_set_selections_with_fieldswas marked xfail with the reason "fields are not supported in v3". It now runs, filtering only theUnstableSpecificationWarningfor itsS3field. Its multi-field cases passed a 3-element value to a 2-element selection, so a shape check fired before the multi-field check; they now pass matching values.test_set_field_preserves_other_fieldscovers v2, v3, and sharded v3, withread_missing_chunkstrue and false, using every selection type, including a partly written chunk and a missing shard. It fails onmainand passes here.test_set_multiple_fields_as_tuple_raiseschecks the tuple error case.Context
The agent found this bug while reviewing #3996, which fixes the read side (
fields=reads raiseTypeErroron v2 and v3). This PR fixes writes only and does not depend on #3996.test_get_selections_with_fieldsstays xfailed until the read fix lands. This PR replaces the agent's fork draft d-v-b#400; both use the same branch.🤖 Generated with Claude Code