Skip to content

[REFACTOR]: Continue work on cl.__init__.py refactor#867

Merged
genedan merged 6 commits into
mainfrom
#856-init-cleanup
May 28, 2026
Merged

[REFACTOR]: Continue work on cl.__init__.py refactor#867
genedan merged 6 commits into
mainfrom
#856-init-cleanup

Conversation

@genedan
Copy link
Copy Markdown
Collaborator

@genedan genedan commented May 27, 2026

Summary of Changes

  • Move datetime defaults out of Options.
  • Add validation to option getters and setters.
  • Enable resetting of single options.
  • Deprecate cl.array_backend() and cl.auto_sparse()

Related GitHub Issue(s)

#861
#858
#860
#859

Additional Context for Reviewers

It was hard to do this cleanly in multiple PRs, so I hope you can follow this. I found that aside from deprecating 2 functions, the other sub-items were intertwined.

  • 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 affect global datetime handling and package-level configuration used across triangle valuation and utilities; removing deprecated helpers is a breaking API change for callers still using cl.array_backend() or cl.auto_sparse().

Overview
This refactor tightens package configuration in chainladder.__init__: Pandas-derived datetime dtype/unit are now module-level __dt64_dtype__ and __dt64_unit__ (for Pandas 2/3 compatibility), not Options fields. Options gains _validate_option on get/set/reset, a _defaults snapshot, and reset_option(option) to restore one setting or all defaults. cl.array_backend() and cl.auto_sparse() are removed in favor of chainladder.options.set_option.

Triangle valuation and date helpers in core/base.py, core/pandas.py, and utils/utility_functions.py now use the module constants instead of options.DT64_*. Tests were updated accordingly (including single-option reset and invalid-option errors).

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

…option getters and setters. Deprecate cl.array_backend() and cl.auto_sparse()
Comment thread chainladder/__init__.py
Comment thread chainladder/__init__.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.17%. Comparing base (70fe2a5) to head (8030ac6).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
chainladder/__init__.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #867      +/-   ##
==========================================
+ Coverage   87.16%   87.17%   +0.01%     
==========================================
  Files          86       86              
  Lines        5047     5051       +4     
  Branches      648      650       +2     
==========================================
+ Hits         4399     4403       +4     
  Misses        457      457              
  Partials      191      191              
Flag Coverage Δ
unittests 87.17% <95.65%> (+0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

Comment thread chainladder/__init__.py Outdated
pd.Timedelta(1, unit=__dt64_unit__)
)
# Store initial values as defaults.
self.defaults = copy.deepcopy(vars(self))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

_defaults maybe?
and do a hasattr check on _defaults to get rid of the bugbot comment?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I switched it to _defaults and then excluded names beginning with an underscore from the dict. Also did small work on #567, since I noticed there was nothing on top of the file. This is the overall package-level __init__.py so I did a generic description.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

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.

Reviewed by Cursor Bugbot for commit 17953c3. Configure here.

Comment thread chainladder/__init__.py Outdated
Comment thread chainladder/__init__.py Outdated
@genedan genedan merged commit 449b5c1 into main May 28, 2026
17 checks passed
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