Commit ddc09e4
Address PR #346 CI review round 3: P1 period inference + P2 summary label
**P1 (Methodology): _validate_had_panel inferred pre/post by lexicographic sort**
Previously the validator sorted the two period labels alphabetically
and assigned `t_pre=periods[0]`, `t_post=periods[1]`. On supported
string-labelled panels like `("pre", "post")` the alphabetic order is
["post", "pre"], so the code flipped pre and post and then raised on
the treated-period D>0 check for a valid design. Same bug for
`("before", "after")` and any non-alphabetic-chronological label pair.
Fix: identify `t_pre` as the unique period where dose == 0 for ALL
units (HAD paper Section 2 no-unit-untreated convention); `t_post` is
the other period. This is a DGP-consistent invariant, not a string
ordering. If neither period has all-zero dose, raise with the
contract message and per-period nonzero-count diagnostics. If both
periods have all-zero dose, raise (no treatment variation to estimate).
The existing pre-period D=0 check is now tautological and has been
removed since the inference itself enforces the invariant. Behavior
on valid numeric panels (e.g., 2020/2021) is unchanged.
**P2 (Code Quality): summary() hardcoded 'WAS' row label**
`HeterogeneousAdoptionDiDResults.summary()` printed "WAS" as the
parameter label regardless of the resolved design. For Design 1
paths (continuous_near_d_lower, mass_point) the stored
`target_parameter` is "WAS_d_lower" per paper Sections 3.2.2-3.2.4,
so the user-facing output misrepresented the estimand.
Fix: render `self.target_parameter` in the summary row. Now Design 1'
prints "WAS", Design 1 prints "WAS_d_lower", matching the stored
result metadata.
**Tests (+7 regression):**
- TestValidateHadPanel.test_semantic_pre_post_labels_not_lexicographic
- TestValidateHadPanel.test_semantic_pre_post_with_first_treat_col
- TestValidateHadPanel.test_semantic_pre_post_fit_end_to_end
- TestValidateHadPanel.test_before_after_labels
- TestValidateHadPanel.test_no_all_zero_period_raises
- TestValidateHadPanel.test_both_all_zero_periods_raises
- TestResultMethods.test_summary_uses_target_parameter_for_row_label
Targeted regression: 133 HAD tests + 512 total across Phase 1 and
adjacent surfaces, all green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c320dde commit ddc09e4
2 files changed
Lines changed: 134 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
| 292 | + | |
292 | 293 | | |
293 | 294 | | |
294 | 295 | | |
| |||
299 | 300 | | |
300 | 301 | | |
301 | 302 | | |
302 | | - | |
| 303 | + | |
303 | 304 | | |
304 | 305 | | |
305 | 306 | | |
| |||
395 | 396 | | |
396 | 397 | | |
397 | 398 | | |
398 | | - | |
399 | | - | |
| 399 | + | |
| 400 | + | |
400 | 401 | | |
401 | | - | |
| 402 | + | |
402 | 403 | | |
403 | 404 | | |
404 | | - | |
| 405 | + | |
405 | 406 | | |
406 | 407 | | |
407 | 408 | | |
408 | | - | |
| 409 | + | |
409 | 410 | | |
410 | 411 | | |
411 | 412 | | |
412 | 413 | | |
413 | 414 | | |
414 | | - | |
| 415 | + | |
415 | 416 | | |
416 | 417 | | |
417 | 418 | | |
418 | 419 | | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | 420 | | |
423 | 421 | | |
424 | 422 | | |
| |||
446 | 444 | | |
447 | 445 | | |
448 | 446 | | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
455 | 460 | | |
456 | 461 | | |
457 | | - | |
458 | | - | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
459 | 473 | | |
| 474 | + | |
| 475 | + | |
460 | 476 | | |
461 | 477 | | |
462 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
899 | 899 | | |
900 | 900 | | |
901 | 901 | | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
902 | 938 | | |
903 | 939 | | |
904 | 940 | | |
| |||
1430 | 1466 | | |
1431 | 1467 | | |
1432 | 1468 | | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
1433 | 1533 | | |
1434 | 1534 | | |
1435 | 1535 | | |
| |||
0 commit comments