Skip to content

Sparse fixes - #1168

Merged
henrydingliu merged 6 commits into
potarafrom
sparse_fixes
Jul 29, 2026
Merged

Sparse fixes#1168
henrydingliu merged 6 commits into
potarafrom
sparse_fixes

Conversation

@henrydingliu

@henrydingliu henrydingliu commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary of Changes

Related GitHub Issue(s)

Additional Context for Reviewers

  • I passed tests locally for both code (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()), so np.asarray(triangle) works without exposing raw COO arrays.

Sparse column reassignment (triangle[col] = value) no longer rebuilds via drop(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 catches AssertionError.

COO __setitem__ is overridden to raise TypeError with guidance to use the numpy backend for in-place slice assignment on triangle.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.

@henrydingliu
henrydingliu merged commit 7e3c8fe into potara Jul 29, 2026
28 of 29 checks passed
@github-actions

Copy link
Copy Markdown

Pyright Type Completeness

View the full pyright --verifytypes output for this commit

Project (full chainladder package, at this PR's head): 14.9% of exported symbols fully typed (194 / 1300)

Known Ambiguous Unknown Total
Project (head) 194 110 996 1300

Other symbols referenced but not exported by chainladder: 13

Known Ambiguous Unknown Total
Other (head) 3 1 9 13

Symbols without documentation:

  • Functions without docstring: 314
  • Functions without default param: 0
  • Classes without docstring: 10

Patch (exported symbols added or changed by this PR): no exported symbol type-completeness changes detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants