Skip to content

[BUG] Fix _pattern not set on older pickles - #1465

Open
henrydingliu wants to merge 15 commits into
casact:mainfrom
henrydingliu:bug/pattern_backup
Open

henrydingliu wants to merge 15 commits into
casact:mainfrom
henrydingliu:bug/pattern_backup

Conversation

@henrydingliu

@henrydingliu henrydingliu commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Summary of Changes

added new path in is_pattern when _pattern is unset
uploaded pickles from older cl versions and added test
consolidated IO tests into new test_io.py (test_utilities.py had too many tests; it wasn't efficient to navigate or test during development)

Related GitHub Issue(s)

closes #1462

AI/LLM Usage

IDE auto-complete for docstring

Additional Context for Reviewers

Submitter's Checklist

  • I have reviewed and am adhering to the standards outlined in the project Governing Doc.
  • The PR subject title summarizes the changes, with one proper prefix ([FIX], [FEAT], [DOCS], [TST], [CHORE], or [BRK]).
  • I am a human (not a bot), and this PR form is written by a human.

Reviewer's Checklist

  • The implementation addresses the associated issue(s).
  • The implementation is appropriate, maintainable, and follows ARCHITECTURE.md.
  • PR subject title has the proper prefix and the subject is appropriate.
  • Relevant issue(s) are linked.
  • AI/LLM usage is disclosed and appropriate.
  • Documentation and tests are appropriate.
  • CI tests passed, or any failures are acceptable.
  • Leave a comment with the final recommendation (e.g. approve as is, request a secondary review, or flag an area for more review).

Note

Low Risk
Localized deserialization shim and safer property defaults; no auth or data-path changes beyond making older pickles load correctly.

Overview
Fixes backward compatibility when loading Triangle pickles created before the internal pattern flag was stored as _pattern instead of is_pattern.

Runtime behavior: read_pickle now migrates legacy __dict__ entries (is_pattern → _pattern) after dill.load. Triangle.is_pattern defaults via getattr(..., "_pattern", False), and align_pattern checks self.is_pattern so restored objects behave like newly constructed ones.

Tests & repo hygiene: JSON and pickle round-trip tests (including new backward-compatibility coverage against committed chainladder/utils/data/raa*.pkl fixtures) move into chainladder/core/tests/test_io.py, with corresponding tests removed from test_utilities.py. .gitignore is updated so those sample .pkl files can be versioned despite the global *.pkl ignore.

Minor formatting-only edits in triangle.py and utility test docstrings are also included.

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

@github-actions

github-actions Bot commented Oct 4, 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): 18.2% of exported symbols fully typed (305 / 1673)

Known Ambiguous Unknown Total
Project (head) 305 96 1272 1673

Other symbols referenced but not exported by chainladder: 24

Known Ambiguous Unknown Total
Other (head) 11 1 12 24

Symbols without documentation:

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

Patch (exported symbols added or changed by this PR): 23.1% fully typed (3 / 13); 4 no longer exported

Known Ambiguous Unknown Total
Patch 3 0 10 13
Patch symbol details
Symbol Status Change
chainladder.core.tests.test_io.TestJSON ❌ unknown new
chainladder.core.tests.test_io.TestJSON.test_estimator_json_io ✅ known new
chainladder.core.tests.test_io.TestJSON.test_json_df ✅ known new
chainladder.core.tests.test_io.TestJSON.test_json_for_val ❌ unknown new
chainladder.core.tests.test_io.TestJSON.test_json_subtri ❌ unknown new
chainladder.core.tests.test_io.TestJSON.test_pipeline_json_io ✅ known new
chainladder.core.tests.test_io.TestJSON.test_triangle_json_io ❌ unknown new
chainladder.core.tests.test_io.TestPickle ❌ unknown new
chainladder.core.tests.test_io.TestPickle.test_pickle_backward_compatibility ❌ unknown new
chainladder.core.tests.test_io.TestPickle.test_read_pickle_estimator ❌ unknown new
chainladder.core.tests.test_io.TestPickle.test_read_pickle_triangle ❌ unknown new
chainladder.core.tests.test_io.TestPickle.test_to_pickle_read_pickle ❌ unknown new
chainladder.core.tests.test_io.TestPickle.test_triangle_to_pickle ❌ unknown new
chainladder.utils.tests.test_utilities.test_read_pickle_estimator — no longer exported (was ❌ unknown)
chainladder.utils.tests.test_utilities.test_read_pickle_triangle — no longer exported (was ❌ unknown)
chainladder.utils.tests.test_utilities.test_to_pickle_read_pickle — no longer exported (was ❌ unknown)
chainladder.utils.tests.test_utilities.test_triangle_to_pickle — no longer exported (was ❌ unknown)

@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.

Stale Bugbot comment from a previous run.

Comment thread chainladder/core/tests/test_io.py Resolved
@codecov

codecov Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.08%. Comparing base (f19f289) to head (99f4cc4).
⚠️ Report is 24 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1465      +/-   ##
==========================================
+ Coverage   94.84%   95.08%   +0.24%     
==========================================
  Files          99      101       +2     
  Lines        6424     6535     +111     
  Branches      811      821      +10     
==========================================
+ Hits         6093     6214     +121     
+ Misses        212      203       -9     
+ Partials      119      118       -1     
Flag Coverage Δ
unittests 95.08% <100.00%> (+0.24%) ⬆️

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.

@henrydingliu
henrydingliu marked this pull request as ready for review October 4, 2026 08:38

@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.

Stale Bugbot comment from a previous run.

Comment thread chainladder/core/triangle.py Resolved
@henrydingliu

Copy link
Copy Markdown
Member Author

I'm doing a pre-thanksgiving clean-up.

converting this to draft to address bugbot

@henrydingliu
henrydingliu marked this pull request as draft November 18, 2026 16:19

@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 2 potential issues.

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 1e01be8. Configure here.

Comment thread chainladder/core/triangle.py Resolved
Comment thread chainladder/utils/utility_functions.py Resolved
@henrydingliu
henrydingliu marked this pull request as ready for review November 18, 2026 16:46
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.

[BUG] _pattern attribute causes IO failure

1 participant