Skip to content

docs(tutorials): fix broken Oregon tutorial code - #139

Merged
TomeHirata merged 1 commit into
mainfrom
docs/fix-oregon-tutorial
Aug 30, 2026
Merged

docs(tutorials): fix broken Oregon tutorial code#139
TomeHirata merged 1 commit into
mainfrom
docs/fix-oregon-tutorial

Conversation

@TomeHirata

Copy link
Copy Markdown
Collaborator

Companion to #137 for the second tutorial. Verified end-to-end against a local copy of the OHIE Public Use Files.

Summary

  • LPTE x-axis length mismatch (costs and visits). plot(outcome_ed_costs_locations[1:], lpte_...) (n-1 points) against a predict_lpte result of length n (len(locations)-1 for the prepended -1 boundary) crashed inside ax.bar with a broadcast-shape error. Dropped the [1:] on both the costs and visits LPTE plots.
  • Variable-scope collision between the Costs and Visits sections. The Visits section rebound ldte_simple, lower_simple, upper_simple, ldte_ml, lower_ml, upper_ml (and the LPTE analogues) to the visits values, clobbering the ED costs versions computed earlier. The final "Overall Population vs Individual Strata" plot then combined the visits LDTE arrays with outcome_ed_costs_locations, which (a) crashed with a shape mismatch, and (b) would have shown wrong data even if the shapes had matched. Renamed the visits arrays to *_visits_* so the costs arrays stay in scope for the strata comparison plot.

Test plan

  • Ran the full tutorial locally via a scripted extract against the OHIE Public Use Files; all code blocks execute without error and the printed diagnostics (sample sizes, compliance rate, mean outcomes by treatment) are stable.

🤖 Generated with Claude Code

Three issues that prevented the Oregon tutorial from running
end-to-end:

- The LPTE bar plots (both costs and visits) used
  outcome_ed_*_locations[1:] as the x-axis (n-1 points) against a PTE
  vector of length n returned by predict_lpte, causing a broadcast
  shape mismatch inside ax.bar. Dropping the [1:] slice matches the
  shape returned by predict_lpte.
- The Visits section rebound ldte_simple/lower/upper/ldte_ml/... and
  lpte_simple/... to the visits values, clobbering the earlier ED
  costs values. The final "Overall Population vs Individual Strata"
  visualization then plotted the visits arrays against the costs
  locations (a shape mismatch, and semantically wrong even if the
  shapes had matched). Rename the visits arrays to *_visits_* so the
  costs arrays stay in scope for the final comparison plot.

Verified by running the tutorial end-to-end against a local copy of
the OHIE Public Use Files.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 30, 2026 02:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@TomeHirata
TomeHirata merged commit 6e4a8ac into main Aug 30, 2026
10 checks passed
@TomeHirata
TomeHirata deleted the docs/fix-oregon-tutorial branch August 30, 2026 03:02
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.

2 participants