Commit db170bd
Address PR #353 CI review round 4 (1 P1 + 2 P3)
P1 - stringified-label collision guard in stute_joint_pretest:
The core indexed residuals_arrays / fitted_arrays by `str(k)` with
no uniqueness check on the stringified keys. Two distinct raw keys
whose str() forms collide (e.g. {1: ..., "1": ...} both stringify
to "1", or custom objects with identical __str__) would silently
overwrite one entry and then be double-counted in S_joint =
sum(S_k) because the surviving horizon's statistic gets summed
twice while n_horizons still reports K=2. That produces wrong
methodology output with no diagnostic.
Fix: compute the stringified labels once up front and reject any
collision explicitly with a ValueError listing which raw keys
collide to which stringified form. Centralizes the check before
any residual/fitted array is dropped. Replaces the ad-hoc post-hoc
re-keying with a reuse of the pre-computed collision-free list.
P3 - dedupe staggered-filter UserWarning:
`_validate_had_panel_event_study` already warns on the staggered
auto-filter path; both joint-pretest wrappers and the event-study
workflow were re-emitting the same information with a
wrapper-prefixed message. Each staggered call therefore surfaced
two warnings to the user. Removes the secondary emissions;
wrappers now consume `_filter_info` silently. Existing tests still
pass because the validator's own `"Staggered-timing panel
detected"` message satisfies the regex matchers.
P3 - collision regression test: new
`TestStuteJointPretest::test_stringified_key_collision_raises`
exercises (a) the int 1 + str "1" case and (b) a pair of custom
objects with identical __str__ but distinct hash; both must raise
`ValueError` with "collision after str" in the message.
125 tests pass (124 + 1 new R4 collision regression); black/ruff/
mypy clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0040bad commit db170bd
2 files changed
Lines changed: 103 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1976 | 1976 | | |
1977 | 1977 | | |
1978 | 1978 | | |
1979 | | - | |
1980 | | - | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
1981 | 2005 | | |
1982 | 2006 | | |
1983 | 2007 | | |
1984 | | - | |
| 2008 | + | |
1985 | 2009 | | |
1986 | 2010 | | |
1987 | 2011 | | |
| |||
1997 | 2021 | | |
1998 | 2022 | | |
1999 | 2023 | | |
2000 | | - | |
2001 | | - | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
2002 | 2027 | | |
2003 | 2028 | | |
2004 | 2029 | | |
| |||
2242 | 2267 | | |
2243 | 2268 | | |
2244 | 2269 | | |
2245 | | - | |
| 2270 | + | |
2246 | 2271 | | |
2247 | 2272 | | |
2248 | 2273 | | |
| |||
2252 | 2277 | | |
2253 | 2278 | | |
2254 | 2279 | | |
2255 | | - | |
2256 | | - | |
2257 | | - | |
2258 | | - | |
2259 | | - | |
2260 | | - | |
2261 | | - | |
2262 | | - | |
2263 | | - | |
2264 | | - | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
2265 | 2284 | | |
2266 | 2285 | | |
2267 | 2286 | | |
| |||
2429 | 2448 | | |
2430 | 2449 | | |
2431 | 2450 | | |
2432 | | - | |
| 2451 | + | |
2433 | 2452 | | |
2434 | 2453 | | |
2435 | 2454 | | |
| |||
2439 | 2458 | | |
2440 | 2459 | | |
2441 | 2460 | | |
2442 | | - | |
2443 | | - | |
2444 | | - | |
2445 | | - | |
2446 | | - | |
2447 | | - | |
2448 | | - | |
2449 | | - | |
2450 | | - | |
2451 | | - | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
2452 | 2465 | | |
2453 | 2466 | | |
2454 | 2467 | | |
| |||
2615 | 2628 | | |
2616 | 2629 | | |
2617 | 2630 | | |
2618 | | - | |
| 2631 | + | |
2619 | 2632 | | |
2620 | 2633 | | |
2621 | 2634 | | |
2622 | 2635 | | |
2623 | 2636 | | |
2624 | 2637 | | |
2625 | 2638 | | |
2626 | | - | |
2627 | | - | |
2628 | | - | |
2629 | | - | |
2630 | | - | |
2631 | | - | |
2632 | | - | |
2633 | | - | |
2634 | | - | |
2635 | | - | |
2636 | | - | |
2637 | | - | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
2638 | 2643 | | |
2639 | 2644 | | |
2640 | 2645 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1575 | 1575 | | |
1576 | 1576 | | |
1577 | 1577 | | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
1578 | 1636 | | |
1579 | 1637 | | |
1580 | 1638 | | |
| |||
0 commit comments