Repository navigation
fix: preserve zero-dimensional arrays in sparse conversions - #963
Merged
hameerabbasi merged 1 commit intoSep 22, 2026
Merged
Conversation
Signed-off-by: 李永祺 <[email protected]>
hameerabbasi
approved these changes
Sep 22, 2026
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.
What type of PR is this? (check all applicable)
Related issues
No separate issue filed. Reproduced on main at
7b075c7.Checklist
Please explain your changes below.
COO.from_iter({(): 5}, shape=())raisesValueError, as does converting a scalar COO with a stored value through DOK back to COO. Empty coordinate tuples get a floating-point dtype and fail coordinate validation. The separate(data, coordinates)form also cannot construct scalars or empty arrays.Keep empty coordinate arrays integer-typed, including the zero-axis case, and handle empty data before accessing its first element. Nonempty fractional coordinates remain invalid. Separately,
DOK.from_numpy(np.array(5))now handles the scalar directly, avoiding the invalid zero-dimensionalnp.nonzerocall and retaining DOK's zero fill value.Validation on Python 3.12.14 / NumPy 2.5.3:
git diff --checkpassed. Other backends and platforms were not tested locally.Prepared with assistance from OpenAI Codex; validation was executed locally.