QuantEcon / QuantEcon/lecture-python.myst
[ar1_turningpts] arviz 1.x: az.plot_trace silently drops the density panels — plot_trace_dist is the 0.x equivalent
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 123
- Forks
- 57
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 11
Description
Summary
Under arviz 1.x, az.plot_trace and az.plot_trace_dist are two different plots, and the name that carries over from arviz 0.x is the wrong one. lectures/ar1_turningpts.md was correctly migrated to plot_trace_dist in #584, but PR #1020 changes it back to plot_trace, which silently drops the marginal density panels from the figure. lectures/ar1_bayes.md has the same problem, left over from the #930 build fix, and was never migrated.
Neither case fails the build — the figure just quietly loses half its content.
What changed in arviz 1.x
Straight from the 1.2.0 docstrings:
| function | arviz 1.x docstring | equivalent in arviz 0.x |
|---|---|---|
az.plot_trace |
"Plot iteration versus sampled values." | no direct equivalent — trace lines only |
az.plot_trace_dist |
"Plot 1D marginal distributions and iteration versus sampled values." | this is the old az.plot_trace |
So a lecture that used az.plot_trace under 0.x and still calls az.plot_trace under 1.x renders a strictly smaller figure than it used to, with no warning and no error. plot_trace_dist is the call that preserves the original output.
Affected lectures
| lecture | current call | status |
|---|---|---|
lectures/ar1_turningpts.md (in draw_from_posterior) |
az.plot_trace_dist(plot_data, var_names=['ρ', 'σ']) on main → az.plot_trace(...) in #1020 |
regression introduced by #1020; main is currently correct |
lectures/ar1_bayes.md (two call sites, az.plot_trace(trace) and az.plot_trace(trace_y0)) |
az.plot_trace |
never migrated; densities missing on main today |
How this happened
The three commits tell the story:
- 2026-06-25, #930 — dropped the
figsizekwarg fromaz.plot_traceinar1_turningpts.mdto unbreak the build under arviz 1.x. A minimal fix that left the call as trace-only. - 2026-07-16, #584 — deliberately upgraded
ar1_turningpts.mdtoaz.plot_trace_dist(plot_data, var_names=['ρ', 'σ']), restoring the density panels.ar1_bayes.mdwas not touched. - 2026-07-31, #1020 — reverts
ar1_turningpts.mdback toaz.plot_trace, undoing #584. Most likely a 0.x-from-memory correction, sinceplot_traceis the name everyone knows.
Suggested fix
Standardise on az.plot_trace_dist in both lectures: revert the ar1_turningpts.md line in #1020 back to plot_trace_dist, and update the two ar1_bayes.md call sites to match. Both lectures install arviz unpinned at runtime, so neither should pin a version — fix forward to the 1.x API, consistent with how the other in-lecture pip packages are handled.
Worth a short comment at the call site noting that plot_trace_dist is the 1.x name for what used to be plot_trace, so the next person reading it doesn't "fix" it again.
Related
Same arviz 0.x → 1.x class of breakage as the az.from_dict and az.summary failures in sargent_surico.md, diagnosed in QuantEcon/lecture-python.myst#1020. Earlier instances: #929, #935.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the affected call sites in lectures/ar1_turningpts.md and lectures/ar1_bayes.md, comparing them with the migration described in the issue. Restore az.plot_trace_dist in ar1_turningpts.md and update both ar1_bayes.md calls, then render or build the lectures and confirm the marginal density panels are present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization, documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100