Skip to content

fix(parallelogram): drop the daily lookback window by date, not row count - #1221

Open
SAY-5 wants to merge 1 commit into
casact:mainfrom
SAY-5:fix-olf-daily-leap-lookback
Open

fix(parallelogram): drop the daily lookback window by date, not row count#1221
SAY-5 wants to merge 1 commit into
casact:mainfrom
SAY-5:fix-olf-daily-leap-lookback

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 16, 2026

Copy link
Copy Markdown

Summary of Changes

With approximation_grain="D", parallelogram_olf removed the lookback window with iloc[366 * lookback_years + leap_day:]. When the lookback year itself is a leap year (a triangle starting 2017 with a 2016 lookback), 366 rows lands on 2016-12-31 rather than 2017-01-01, so the non-leap frame keeps a one-day 2016 origin the leap frame does not have, the positional join misaligns the two, and fit() fails with ValueError: operands could not be broadcast together with shapes (1,1,3,1) (1,1,4,1). The lookback is now dropped by date (index >= first_date), which is independent of leap days and leaves the same origins in both frames. The existing daily-grain expectations are unchanged.

Related GitHub Issue(s)

Fixes #1219

Additional Context for Reviewers

Added test_daily_grain_after_leap_year with the repro from the issue.

Checklist

  • I passed tests locally for both code (uv run pytest) and documentation changes (uv run --directory docs jb build . --builder=custom --custom-builder=doctest)

…ount

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@github-actions

Copy link
Copy Markdown

Pyright Type Completeness

View the full pyright --verifytypes output for this commit

Project (full chainladder package, at this PR's head): 15.1% of exported symbols fully typed (202 / 1337)

Known Ambiguous Unknown Total
Project (head) 202 111 1024 1337

Other symbols referenced but not exported by chainladder: 13

Known Ambiguous Unknown Total
Other (head) 3 1 9 13

Symbols without documentation:

  • Functions without docstring: 324
  • Functions without default param: 0
  • Classes without docstring: 10

Patch (exported symbols added or changed by this PR): 0.0% fully typed (0 / 1)

Known Ambiguous Unknown Total
Patch 0 0 1 1
Patch symbol details
Symbol Status Change
chainladder.adjustments.tests.test_parallelogram.test_daily_grain_after_leap_year ❌ unknown new

@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.27%. Comparing base (606be5c) to head (a11ab4a).
⚠️ Report is 20 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1221   +/-   ##
=======================================
  Coverage   91.27%   91.27%           
=======================================
  Files          91       91           
  Lines        5411     5412    +1     
  Branches      692      692           
=======================================
+ Hits         4939     4940    +1     
  Misses        338      338           
  Partials      134      134           
Flag Coverage Δ
unittests 91.27% <100.00%> (+<0.01%) ⬆️

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

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

@priyam0k

Copy link
Copy Markdown
Collaborator

@SAY-5 Welcome to the repo and thanks for putting this PR together so quickly.

@priyam0k priyam0k left a comment

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.

The solution is correct. Let maintainers have their final review.

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.

ParallelogramOLF daily grain ValueError after leap year

2 participants