Repository navigation
Fix asarray when chunk dims are greater than shape dims - #698
Merged
FrancescAlted merged 3 commits intoAug 11, 2026
Merged
Conversation
Above 16 MB, asarray fills chunk by chunk through SChunk.update_data(), guarded by are_partitions_behaved(). That guard only rejected partitions smaller than their container, so chunks sticking out of the shape (e.g. shape (146, 23802), chunks (147, 23802)) passed, and update_data() got a slice one row short of the padded chunkshape; reading the array back failed with "Error while getting the buffer". Rejecting overhanging partitions collapses check_contiguity() to its two real conditions: unsplit innermost dimension, outer dimensions divided evenly.
Member
|
Well seen, and the fix looks good to me. Merging. Thanks @Zentrik ! |
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.
asarray()leaves arrays over 16 MB unreadable when the chunk shape is greater than the shape:This seems to be because
asarrayhas a separate path for large arrays which callsschunk.update_data()on its fastpath ifare_partitions_behaved. I have changedare_partitions_behavedto no longer return true for this example and tried to simplify the existing logic which I found hard to follow. I've tried to preserve the old behaviour whilst also checking thatsize % unit == 0ifsize < unit.The other uses of
are_partitions_behavedseem to live inlazyexpr.pyand are of the formbehaved and result.shape == out.chunks and result.dtype == out.dtypeso I think they're unaffected.