Sparse fixes - #1168
Merged
Merged
Conversation
henrydingliu
requested review from
genedan,
jbogaardt and
kennethshsu
as code owners
July 29, 2026 05:01
Pyright Type CompletenessView the full Project (full
Other symbols referenced but not exported by
Symbols without documentation:
Patch (exported symbols added or changed by this PR): no exported symbol type-completeness changes detected. |
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.
Summary of Changes
Related GitHub Issue(s)
Additional Context for Reviewers
uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)Note
Medium Risk
Changes core Triangle value storage and column assignment on the sparse path, which affects numerical workflows on large sparse triangles; risk is mitigated by expanded tests and explicit errors for unsupported in-place mutation.
Overview
Improves sparse-backed Triangle behavior: numpy interoperability, column assignment, and clearer errors when mutating sparse storage directly.
Triangle.__array__now returns a dense ndarray for sparse triangles (values.todense()), sonp.asarray(triangle)works without exposing raw COO arrays.Sparse column reassignment (
triangle[col] = value) no longer rebuilds viadrop(key); it filters the target column out of the existing COO coordinates and merges new data, and accepts raw COO arrays as well as Triangle values. Misaligned new-column concatenation also catchesAssertionError.COO
__setitem__is overridden to raiseTypeErrorwith guidance to use the numpy backend for in-place slice assignment ontriangle.values.CI: pytest workflow adds concurrency with cancel-in-progress for duplicate runs on the same ref.
Tests are updated to branch on backend (sparse vs numpy) instead of assuming numpy-only fixtures.
Reviewed by Cursor Bugbot for commit 254ca05. Bugbot is set up for automated code reviews on this repo. Configure here.