Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
d473402
adding support for multi-triangle in mackchainladder
henrydingliu May 28, 2026
f06536d
Added development_format
kennethshsu Jun 4, 2026
3993b4a
removed the development_format from friedland_med_mal
kennethshsu Jun 4, 2026
31b3432
Merge pull request #921 from casact/#919_-friedland_gl_self_insurer_g…
kennethshsu Jun 4, 2026
16ef951
Update friedland_wc_self_insurer.csv
henrydingliu Jun 5, 2026
db13fbe
Update friedland_auto_freq_sev.csv
henrydingliu Jun 5, 2026
c455297
Update friedland_wc_self_insurer.csv
henrydingliu Jun 5, 2026
4c6a90d
Update friedland_auto_freq_sev.csv
henrydingliu Jun 5, 2026
174ba3d
Update _manifest.py
henrydingliu Jun 5, 2026
2233c64
Delete chainladder/utils/data/friedland_xyz_freq_sev.csv
henrydingliu Jun 5, 2026
31d54f3
Update friedland_xyz_auto_bi.csv
henrydingliu Jun 5, 2026
6d2d727
Delete chainladder/utils/data/friedland_xyz_case.csv
henrydingliu Jun 5, 2026
4784ee7
Update _manifest.py
henrydingliu Jun 5, 2026
cc4756f
Update chapter_6.rst
henrydingliu Jun 5, 2026
a708691
FIX: Make quarterly.csv development dates ISO 8601-compatible.
genedan Jun 5, 2026
1dd5f1d
Merge pull request #930 from casact/#928-quarterly_warning_attempt_2
genedan Jun 5, 2026
f0f6f27
TST: Add unit tests to cover missing lines in base.py.
genedan Jun 7, 2026
2c9242e
Merge branch 'main' into base_unit_tests
genedan Jun 7, 2026
71923fc
FIX: Fix typo in test, but in column type checking.
genedan Jun 7, 2026
579a7b6
FIX: Fix for pandas 3.
genedan Jun 7, 2026
1284204
FIX: Fix for pandas 3.
genedan Jun 7, 2026
894f5f7
Deprecate dask array backend (#842)
priyam0k Jun 7, 2026
4caefb7
Gate dask warning to actual dask dataframes (#842)
priyam0k Jun 7, 2026
36f1078
Merge pull request #936 from casact/base_unit_tests
genedan Jun 7, 2026
68b6183
Merge pull request #927 from casact/various_friedland_fix
kennethshsu Jun 7, 2026
7d89675
TST: Add tests for missing lines in _LocBase.
genedan Jun 7, 2026
f926c14
DOCS: Add type aliases for Triangle, IndexExpression, and _AxisKey.
genedan Jun 7, 2026
4fa434f
TST: Exclude typing.py from coverage.
genedan Jun 7, 2026
3fb06e8
DOCS: Add annotations, typing, and return consistent tuples for key f…
genedan Jun 7, 2026
a959753
Merge branch 'main' into base_unit_tests
genedan Jun 7, 2026
723ca88
FIX: Apply Bugbot fixes.
genedan Jun 7, 2026
bcf728f
FIX: Apply Bugbot fixes.
genedan Jun 7, 2026
a905852
FIX: Apply Bugbot fixes.
genedan Jun 7, 2026
59d06f5
Merge pull request #937 from priyam0k/feature/842-deprecate-dask
genedan Jun 8, 2026
11f6263
Merge pull request #938 from casact/base_unit_tests
genedan Jun 8, 2026
5755a6f
TST: Add tests for missing lines in slice.py.
genedan Jun 8, 2026
79e871f
DOCS: Add typing and annotations.
genedan Jun 8, 2026
c0e2b8c
FIX: Code cleanup to handle warnings.
genedan Jun 8, 2026
f133542
TST: Add more meaningful assertions and annotations.
genedan Jun 9, 2026
85b49d0
FIX: Fix boundary on development slicing test.
genedan Jun 9, 2026
219b586
FIX: Fix boundary on development slicing test.
genedan Jun 9, 2026
07ec79c
Switching codecov to main
kennethshsu Jun 9, 2026
a6895c9
Merge pull request #947 from casact/#935_codecov_readme_badge
kennethshsu Jun 9, 2026
b24f209
Merge pull request #946 from casact/slicing_tests
genedan Jun 10, 2026
cf7f375
Merge pull request #873 from casact/#871-mack-fix
kennethshsu Jun 11, 2026
86b8dac
Update test_predict.py
henrydingliu Jun 12, 2026
d001e98
Update triangle.py
henrydingliu Jun 12, 2026
f30625c
Update base.py
henrydingliu Jun 12, 2026
a49bf34
Update test_triangle.py
henrydingliu Jun 12, 2026
d538c80
Merge pull request #953 from casact/fix-and-enhance-utils.model_diagn…
kennethshsu Jun 12, 2026
b6b167b
Update benktander.py
henrydingliu Jun 12, 2026
dd38aae
Update test_predict.py
henrydingliu Jun 12, 2026
d148538
Merge pull request #954 from casact/fix-and-enhance-utils.model_diagn…
kennethshsu Jun 12, 2026
cdd8371
Merge pull request #955 from casact/fix-and-enhance-utils.model_diagn…
henrydingliu Jun 12, 2026
169923e
docs(utilities): live list_samples table + model_diagnostics demo (#915)
SaguaroDev Jun 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# .coveragerc to control coverage.py
[run]
branch = True
omit = *tests*
omit =
*tests*
*/core/typing.py

[report]
show_missing = True
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
.. |Build Status| image:: https://github.com/casact/chainladder-python/actions/workflows/pytest.yml/badge.svg
:target: https://github.com/casact/chainladder-python/actions/workflows/pytest.yml

.. |codecov io| image:: https://codecov.io/gh/casact/chainladder-python/branch/master/graphs/badge.svg
.. |codecov io| image:: https://codecov.io/gh/casact/chainladder-python/branch/main/graphs/badge.svg
:target: https://codecov.io/github/casact/chainladder-python?branch=latest

.. |Documentation Status| image:: https://readthedocs.org/projects/chainladder-python/badge/?version=main
Expand Down
55 changes: 37 additions & 18 deletions chainladder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@
"The parameter 'option' is deprecated and will be removed in a future release. Use 'pat' instead."
)

# Array backends slated for removal, mapped to the issue tracking each one.
# Selecting one of these (via set_option, ARRAY_PRIORITY, or set_backend, or by
# passing a Dask dataframe to the Triangle constructor) emits a
# DeprecationWarning.
_DEPRECATED_BACKENDS: dict[str, str] = {
"cupy": "https://github.com/casact/chainladder-python/issues/843",
"dask": "https://github.com/casact/chainladder-python/issues/842",
}


def _deprecated_backend_message(backend: str) -> str:
"""Build the deprecation message for a soon-to-be-removed array backend."""
return (
f"The '{backend}' array backend is deprecated and will be removed in a "
f"future release. See {_DEPRECATED_BACKENDS[backend]}."
)


@overload
def _resolve_pat(pat: str | None, option: str | None, required: Literal[True] = ...) -> str: ...
Expand Down Expand Up @@ -189,28 +206,30 @@ def set_option(
self._validate_option(pat)
if value is _UNSET:
raise TypeError("set_option() missing required argument: 'value'.")
if pat == "ARRAY_BACKEND" and value == "cupy":
if pat == "ARRAY_BACKEND" and value in _DEPRECATED_BACKENDS:
warnings.warn(
"The 'cupy' array backend is deprecated and will be removed in a "
"future release. See https://github.com/casact/chainladder-python/issues/843.",
_deprecated_backend_message(value),
DeprecationWarning,
stacklevel=2,
)
elif pat == "ARRAY_PRIORITY" and isinstance(value, list) and "cupy" in value:
# Only warn when 'cupy' is prioritized ahead of a non-deprecated
# backend ('numpy' or 'sparse'), i.e. cupy would actually be
# selected over a supported backend.
cupy_index = value.index("cupy")
if any(
backend in value and value.index(backend) > cupy_index
for backend in ("numpy", "sparse")
):
warnings.warn(
"The 'cupy' array backend is deprecated and will be removed in a "
"future release. See https://github.com/casact/chainladder-python/issues/843.",
DeprecationWarning,
stacklevel=2,
)
elif pat == "ARRAY_PRIORITY" and isinstance(value, list):
# Only warn when a deprecated backend ('cupy' or 'dask') is
# prioritized ahead of a non-deprecated backend ('numpy' or
# 'sparse'), i.e. it would actually be selected over a supported
# backend. The position in the list determines precedence.
for backend in _DEPRECATED_BACKENDS:
if backend not in value:
continue
backend_index = value.index(backend)
if any(
supported in value and value.index(supported) > backend_index
for supported in ("numpy", "sparse")
):
warnings.warn(
_deprecated_backend_message(backend),
DeprecationWarning,
stacklevel=2,
)
setattr(self, pat, value)

def reset_option(
Expand Down
17 changes: 15 additions & 2 deletions chainladder/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from chainladder import (
__dt64_unit__,
__dt64_dtype__,
options
options,
_deprecated_backend_message
)

from chainladder.core.common import Common
Expand Down Expand Up @@ -105,7 +106,7 @@ def str_to_list(arg: str | list) -> None | list:
columns = str_to_list(columns)
origin = str_to_list(origin)
development = str_to_list(development)
if "object" in data[columns].dtypes:
if not all(pd.api.types.is_numeric_dtype(dt) for dt in data[columns].dtypes):
raise TypeError("column attribute must be numeric.")
if data[columns].shape[1] != len(columns):
raise AttributeError("Columns are required to have unique names")
Expand Down Expand Up @@ -162,6 +163,18 @@ def _aggregate_data(
):
"""Summarize dataframe to the level specified in axes"""
if type(data) != pd.DataFrame:
# A non-pandas input that reaches this branch is a Dask dataframe.
# Only the Dask backend is deprecated, so gate the warning on the
# data's module rather than warning for every pandas subclass that
# also takes this path. stacklevel=3 points the warning at the
# user's Triangle(...) call (warn -> this method ->
# Triangle.__init__ -> user).
if type(data).__module__.split(".")[0] == "dask":
warnings.warn(
_deprecated_backend_message("dask"),
DeprecationWarning,
stacklevel=3,
)
# Dask dataframes are mutated.
data["__origin__"] = origin_date
data["__development__"] = development_date
Expand Down
6 changes: 3 additions & 3 deletions chainladder/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pandas as pd

from chainladder import options
from chainladder import _DEPRECATED_BACKENDS, _deprecated_backend_message
from chainladder.utils.cupy import cp
from chainladder.utils.dask import dp
from chainladder.utils.sparse import sp
Expand Down Expand Up @@ -180,10 +181,9 @@ def set_backend(
# Warn once, at the public entry point, so stacklevel=2 points at the
# user's call site rather than an internal recursive call. The _warn
# flag suppresses duplicate warnings from internal recursion below.
if _warn and backend == "cupy":
if _warn and backend in _DEPRECATED_BACKENDS:
warnings.warn(
"The 'cupy' array backend is deprecated and will be removed in a "
"future release. See https://github.com/casact/chainladder-python/issues/843.",
_deprecated_backend_message(backend),
DeprecationWarning,
stacklevel=2,
)
Expand Down
Loading
Loading