Skip to content

Sparse fixes - #1164

Open
genedan wants to merge 6 commits into
mainfrom
sparse_fixes
Open

Sparse fixes#1164
genedan wants to merge 6 commits into
mainfrom
sparse_fixes

Conversation

@genedan

@genedan genedan commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary of Changes

Remove blockage for #1157.

Related GitHub Issue(s)

#1155

Additional Context for Reviewers

Trying to fix this revealed some bugs, mainly in-place assignment to Triangle.values with a sparse backend, which I explicitly forbid (earlier, would have just failed with a cryptic error message). The other was assignment to a Triangle column, which had a bug.

  • 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 many estimators rely on; risk is mitigated by expanded tests and clearer failure modes for unsupported in-place mutation.

Overview
Fixes sparse backend behavior around column assignment, numpy interoperability, and mutating values, unblocking related work on sparse triangles (#1155 / #1157).

Sparse column assignment (Triangle[...] = value): Replacing an existing column no longer rebuilds via drop(key); it filters the target column out of the current COO coordinates and merges new data. Assignments can use a Triangle or a raw COO array, aligned with the numpy path. Misaligned new-column concatenation also catches AssertionError.

In-place values writes on sparse are explicitly rejected: COO.__setitem__ raises a clear TypeError directing users to the numpy backend (instead of obscure failures). __array__ on sparse triangles returns a dense array so np.asarray(triangle) behaves predictably.

CI adds workflow concurrency so duplicate pytest runs on the same branch/ref cancel in-progress jobs.

Tests are updated to run on both backends where relevant and to expect or skip in-place values mutation on sparse.

Reviewed by Cursor Bugbot for commit 254ca05. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Jul 29, 2026

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.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.27%. Comparing base (a9f45e1) to head (254ca05).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1164      +/-   ##
==========================================
+ Coverage   90.94%   91.27%   +0.32%     
==========================================
  Files          91       91              
  Lines        5325     5422      +97     
  Branches      675      691      +16     
==========================================
+ Hits         4843     4949     +106     
+ Misses        344      339       -5     
+ Partials      138      134       -4     
Flag Coverage Δ
unittests 91.25% <100.00%> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5cb7d16. Configure here.

Comment thread chainladder/core/slice.py

@henrydingliu henrydingliu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passes sparse tests here

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