Repository navigation
Conversation
Triangle.valuation stamps each cell at the last instant of its period, while pandas reads a date bound as midnight at the start of the day, so a valuation <= filter with a period-end date drops that period (casact#1608). Say so in the valuation docstring and the triangle user guide, and add as_of, which keeps every cell valued on or before the end of the named day or period. Developed with an AI assistant (Árbol, running Muse).
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): 0.0% fully typed (0 / 6)
Patch symbol details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1620 +/- ##
=======================================
Coverage 94.94% 94.94%
=======================================
Files 99 99
Lines 6425 6432 +7
Branches 811 812 +1
=======================================
+ Hits 6100 6107 +7
Misses 207 207
Partials 118 118
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:
|
== between two triangles is deprecated in favour of Triangle.equals and emits a FutureWarning, so the new as_of tests call equals directly. Developed with an AI assistant (Árbol, running Muse).
|
|
||
| @property | ||
| def valuation(self): | ||
| """ |
There was a problem hiding this comment.
thanks for writing this all out. unfortunately we aren't displaying the docstring of every property, so this isn't showing up in the API reference.
| date : str, int, pandas.Period or date-like | ||
| A string or integer names the period it spells: ``"1988"`` or | ||
| ``1988`` is the year 1988, ``"1988Q2"`` a quarter, ``"1988-06"`` | ||
| a month and ``"1988-06-30"`` a day. A ``pandas.Period`` is used |
There was a problem hiding this comment.
can you list these out in bullets?
| .. testcode:: | ||
|
|
||
| raa = cl.load_sample("raa") | ||
| print(raa.as_of("1988").shape) |
There was a problem hiding this comment.
printing the actual as_of triangle would be a much stronger example
|
|
||
| Keeps every cell valued on or before the end of the period that | ||
| ``date`` names. Valuations are stamped at the last instant of their | ||
| period, while pandas reads a date bound as midnight at the start of |
There was a problem hiding this comment.
this is a tad verbose.
also "valuation period" is pure hallucinated term in this context. AI isn't comprehending that .end_time is just a short-cut implementation.
| ``as_of`` keeps the diagonal valued at the end of the named period, which | ||
| a ``valuation <=`` filter with the same date leaves out (#1608). | ||
| """ | ||
| expected = raa[raa.valuation < "1989"] |
There was a problem hiding this comment.
can you confirm that tri[tri.valuation < year_str] is explicitly tested somewhere?
Summary of Changes
Triangle.valuationstamps each cell at the last instant of its period, while pandas reads a date bound as midnight at the start of the day, soraa[raa.valuation <= "1988-12-31"]returns the triangle as of 1987 (#1608). As agreed in #1608, this PR adds the docs note and a helper, and leaves the stamping alone until #1304 is merged:valuationthat says how the dates are stamped and how to filter through the end of a period;Triangle.as_of(date), which keeps every cell valued on or before the end of the perioddatenames. A string or integer names the period it spells ("1988",1988,"1988Q2","1988-06","1988-06-30"), apandas.Periodis used as given, and aTimestamp,datetime,dateornumpy.datetime64counts as its whole day. It returnsself[self.valuation <= period.end_time];Tests: seven ways of naming 1988 give the same result as
raa[raa.valuation < "1989"]; a date inside 1988 stops at 1987;"1995Q2"and"1995-06-30"give the same slice of the quarterly sample; the latest valuation date and a later date return the whole triangle; a date before the first valuation raises.Related GitHub Issue(s)
Part of #1608 (the docs note and the helper). The stamping question stays open there until #1304 is merged.
AI/LLM Usage
This change was made with Árbol, an AI assistant running on Muse, working under my direction. It wrote the change, the tests and the docs, ran the checks and drafted this description. I reviewed the diff and the results before submitting.
Additional Context for Reviewers
The
as_ofbehaviour (keep every cell valued on or before the end of the named day or period) is the one agreed in #1608. The midnight-stamping change is left for after #1304, as discussed there.Submitter's Checklist
[FIX],[FEAT],[DOCS],[TST],[CHORE], or[BRK]).Reviewer's Checklist