fix(fundamentals): pure-core review — tie-aware percentile, null-safe reads
1. Peer percentile is now a tie-aware rank against the OTHER issuers ((worse + 0.5*tied)/(peers-1)): an all-equal group maps to 50 (not 100), the median maps to 50, a unique best to 100, a unique worst to 0. 2. Deterministic reads use the consecutive non-null suffix ending at the latest point (>=3 values): a null latest or an internal gap yields no read, so a read never reflects a period displayed as n/a. 3. Peer filtering excludes non-finite (NaN/±inf) as well as null, including an invalid subject. Tests updated + added (all-equal, median rank, non-finite, latest-null history, internal gap). 15 passed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,16 @@ def test_growth_read_boundaries():
|
||||
assert rd.growth_read(_hist(5, 6)) is None # < 3 periods
|
||||
|
||||
|
||||
def test_reads_use_latest_nonnull_suffix():
|
||||
# latest displayed value is n/a -> no read (never reflect a null latest)
|
||||
assert rd.growth_read(_hist(5, 6, 8, None)) is None
|
||||
assert rd.margin_read(_hist(19, 20, 22, None)) is None
|
||||
# an internal gap truncates the run -> fewer than 3 consecutive -> no read
|
||||
assert rd.growth_read(_hist(5, 6, None, 8)) is None
|
||||
# a clean 3-run after an older gap still reads
|
||||
assert rd.growth_read(_hist(None, 5, 6, 8)) == "accelerating"
|
||||
|
||||
|
||||
def test_margin_read_vs_mean_of_prior():
|
||||
# prior mean = (19+20)/2 = 19.5; latest 21 -> +1.5 -> improving
|
||||
assert rd.margin_read(_hist(19, 20, 21)) == "improving"
|
||||
|
||||
Reference in New Issue
Block a user