Skip to content

Commit d998ab0

Browse files
author
John Bogaardt
committed
prep for 0.8.16
1 parent 9b8b10c commit d998ab0

File tree

5 files changed

+35
-25
lines changed

5 files changed

+35
-25
lines changed

chainladder/core/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def _to_datetime(data, fields, period_end=False, format=None):
256256
def _development_lag(origin, valuation):
257257
"""For tabular format, this will convert the origin/valuation
258258
difference to a development lag"""
259-
return ((valuation - origin) / (365/12)).round('1d').dt.days
259+
return ((valuation - origin) / (365.25/12)).round('1d').dt.days
260260

261261

262262
@staticmethod

chainladder/core/pandas.py

-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ def add_groupby_agg_func(cls, k, v):
389389

390390
def agg_func(self, *args, **kwargs):
391391
from chainladder.utils import concat
392-
393392
xp = self.obj.get_array_module()
394393
obj = self.obj.copy()
395394
auto_sparse = kwargs.pop("auto_sparse", True)

chainladder/core/slice.py

+8-22
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,22 @@ def __init__(self, obj):
1414

1515
def get_idx(self, idx):
1616
""" Returns a slice of the original Triangle """
17-
from chainladder.core.triangle import Triangle
18-
obj = Triangle()
17+
obj = self.obj.copy()
1918
i_idx = _LocBase._contig_slice(idx[0])
2019
c_idx = _LocBase._contig_slice(idx[1])
2120
o_idx = _LocBase._contig_slice(idx[2])
2221
d_idx = _LocBase._contig_slice(idx[3])
2322
if type(o_idx) != slice or type(d_idx) != slice:
2423
raise ValueError("Fancy indexing on origin/development is not supported.")
2524
if type(i_idx) is slice or type(c_idx) is slice:
26-
obj.values = self.obj.values[i_idx, c_idx, o_idx, d_idx]
25+
obj.values = obj.values[i_idx, c_idx, o_idx, d_idx]
2726
else:
28-
obj.values = self.obj.values[i_idx, :, o_idx, d_idx][:, c_idx, ...]
29-
obj.kdims = self.obj.kdims[i_idx]
30-
obj.vdims = self.obj.vdims[c_idx]
31-
obj.odims = self.obj.odims[o_idx]
32-
obj.ddims = self.obj.ddims[d_idx]
33-
obj.iloc = Ilocation(obj)
34-
obj.loc = Location(obj)
35-
obj.origin_grain = self.obj.origin_grain
36-
obj.development_grain = self.obj.development_grain
37-
obj.key_labels = self.obj.key_labels
38-
obj.origin_close = self.obj.origin_close
39-
obj.is_pattern = self.obj.is_pattern
40-
obj.is_cumulative = self.obj.is_cumulative
41-
obj.virtual_columns = self.obj.virtual_columns
42-
obj.array_backend = self.obj.array_backend
43-
obj.valuation_date = self.obj.valuation_date
44-
obj.valuation_date = np.minimum(obj.valuation.max(), self.obj.valuation_date)
45-
for t in self.obj.subtriangles + ['w_'] if hasattr(self.obj, 'w_') else []:
46-
setattr(obj, t, getattr(self.obj, t))
27+
obj.values = obj.values[i_idx, :, o_idx, d_idx][:, c_idx, ...]
28+
obj.kdims = obj.kdims[i_idx]
29+
obj.vdims = obj.vdims[c_idx]
30+
obj.odims, obj.ddims = obj.odims[o_idx], obj.ddims[d_idx]
31+
obj.iloc, obj.loc = Ilocation(obj), Location(obj)
32+
obj.valuation_date = np.minimum(obj.valuation.max(), obj.valuation_date)
4733
return obj
4834

4935
@staticmethod

chainladder/development/development.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ class Development(DevelopmentBase):
4343
The minimum number of link ratio(s) required for LDF calculation
4444
drop_valuation: str or list of str (default = None)
4545
Drops specific valuation periods. str must be date convertible.
46+
fillna: float, (default = None)
47+
Used to fill in zero or nan values of an triangle with some non-zero
48+
amount. When an link-ratio has zero as its denominator, it is automatically
49+
excluded from the ``ldf_`` calculation. For the specific case of 'volume'
50+
averaging in a deterministic method, this may be reasonable. For all other
51+
averages and stochastic methods, this assumption should be avoided.
4652
groupby:
4753
An option to group levels of the triangle index together for the purposes
4854
of estimating patterns. If omitted, each level of the triangle
@@ -115,7 +121,10 @@ def fit(self, X, y=None, sample_weight=None):
115121
# Triangle must be cumulative and in "development" mode
116122
obj = self._set_fit_groups(X).incr_to_cum().val_to_dev().copy()
117123
xp = obj.get_array_module()
118-
tri_array = num_to_nan(obj.values.copy())
124+
if self.fillna:
125+
tri_array = num_to_nan((obj + self.fillna).values)
126+
else:
127+
tri_array = num_to_nan(obj.values.copy())
119128
average_ = self._validate_assumption(X, self.average, axis=3)[... , :X.shape[3]-1]
120129
self.average_ = average_.flatten()
121130
n_periods_ = self._validate_assumption(X, self.n_periods, axis=3)[... , :X.shape[3]-1]

docs/library/releases.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
# {octicon}`megaphone` Releases & Changelog
22

33
## Version 0.8
4+
### Version 0.8.16
5+
6+
Release Date: Jun 17, 2023
7+
8+
**What's Changed**
9+
* fix for [\#409](https://github.com/casact/chainladder-python/issues/409)
10+
* fix for [\#411](https://github.com/casact/chainladder-python/issues/411)
11+
* fix for [\#438](https://github.com/casact/chainladder-python/issues/438)
12+
13+
## New Contributors
14+
* [@MatthewCaseres](https://github.com/MatthewCaseres) made their first contribution.
15+
* [@andrejakobsen](https://github.com/andrejakobsen) made their first contribution.
16+
17+
18+
19+
420

521
### Version 0.8.15
622

0 commit comments

Comments
 (0)