Common tests#1082
Conversation
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): 5.9% fully typed (1 / 17)
Patch symbol details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1082 +/- ##
==========================================
+ Coverage 89.75% 89.97% +0.22%
==========================================
Files 91 91
Lines 5408 5288 -120
Branches 696 671 -25
==========================================
- Hits 4854 4758 -96
+ Misses 389 376 -13
+ Partials 165 154 -11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I added tests for the zeta attribute, they seemed succinct enough to tack on to this PR. I'm relying on the prior work of another actuary by using the incrementals in the docs and converting them to cumulative for the scalars in the assert statement: https://chainladder-python.readthedocs.io/stable/user_guide/development.html#incremental-calculation Do I get professionalism CE for doing this? |
|
so these tests would be the first time we actually use set_backend on an estimator in the codebase. honestly not sure if it's something we should encourage, or even allow. many estimators have a xp attribute, which could conflict with a manually set backend during subsequent transforming or predicting. imo we should just take out set_backend from common and put into base (i.e. remove it from estimators). it never made sense to have set_backend on an estimator. |
thanks for these tests. i made a lot of short-sighted edits to the zeta stuff a few years back. it was very hard to work with when i needed something similar but slightly different for disposalrate. we'll probably need to refactor incrementaladditive/zeta a bit for friedland chapter 16. |
Summary of Changes
Adds tests for
Traingle.set_backend()andTriangle._validate_assumption().Related GitHub Issue(s)
Additional Context for Reviewers
I left out testing dask because that is on the deprecation list.
uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)Note
Low Risk
Test and documentation-only changes; no behavioral changes to library code beyond docstrings.
Overview
Adds pytest coverage for
Common.set_backendandCommon._validate_assumptionintest_triangle.py, with a small docstring update on_validate_assumptionincommon.py._validate_assumptiontests now exercise scalars, sequences, dicts, callables, axis 2 vs 3 broadcasting shapes, invalid types, and a NumPy 2.x note forsetinputs.set_backendtests cover backend resolution via fittedldf_,ValueErroron unfitted estimators, in-placearray_backendupdates,deeprecursion into nestedCommonattributes,valuestype changes (numpy ↔ sparseCOO), invalid backend names, and numpy/sparse round-trip equality.Also adds tests for
has_zetaandcum_zeta_onIncrementalAdditivevsDevelopment. Dask backends are intentionally omitted.Reviewed by Cursor Bugbot for commit adeca5b. Bugbot is set up for automated code reviews on this repo. Configure here.