Skip to content

[BUG] TailBondy fails on non-annual triangles and with projection_period outside 12-23 #1623

Open

Description

@scks1

Are you on the latest chainladder version?

  • Yes, this bug occurs on the latest version (main at 46727b1: chainladder 0.10.1, Python 3.12.15, numpy 2.3.3, pandas 2.3.3).

Describe the bug in words

TailBase.fit gives ldf_ one tail column per development period in projection_period plus one for the rest (base.py L27–L39): 2 for annual data at the default, 5 for quarterly, 13 for monthly. TailBondy.fit then rebuilds ldf_.values with 2 tail columns whatever the grain (bondy.py L187–L207), so the values and ddims disagree and nan_triangle fails at core/base.py L512. TailBondy therefore works only on annual triangles with projection_period from 12 to 23. TailConstant fits the same inputs.

A local change evaluates Bondy's curve over every projected period and fills each tail column from it. The annual default output is unchanged, tail_ comes out the same for every projection_period, and the tails tests pass. #1304 edits the same lines without changing the column counts.

How can the bug be reproduced?

import chainladder as cl

raa = cl.Development().fit_transform(cl.load_sample("raa"))
qtr = cl.Development().fit_transform(cl.load_sample("quarterly"))
for name, dev, kw in [
    ("raa", raa, {}),
    ("raa", raa, {"projection_period": 24}),
    ("quarterly", qtr, {}),
]:
    columns = cl.TailConstant(**kw).fit(dev).ldf_.shape[-1]
    try:
        cl.TailBondy(**kw).fit(dev)
        print(name, kw, "fits; TailConstant ldf_ columns:", columns)
    except ValueError as e:
        print(name, kw, "ValueError:", e, "| TailConstant ldf_ columns:", columns)
raa {} fits; TailConstant ldf_ columns: 11
raa {'projection_period': 24} ValueError: cannot reshape array of size 12 into shape (1,11) | TailConstant ldf_ columns: 12
quarterly {} ValueError: cannot reshape array of size 49 into shape (1,46) | TailConstant ldf_ columns: 49

What is the expected behavior?

TailBondy fits every grain and projection_period that TailConstant does, with the same ldf_ columns.

Would you be willing to contribute this ticket?

  • Yes, absolutely!
  • Yes, but I would like some help.
  • No.

(This issue was written with Árbol, an AI assistant, under my direction.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Scope

    None yet

    Effort

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions