Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dimension ordering for traceplot with divergences #2151

Merged
merged 5 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## v0.x.x Unreleased

### New features

### Maintenance and fixes
- Fix dimension ordering for `plot_trace` with divergences ([2151](https://github.com/arviz-devs/arviz/pull/2151))

### Deprecation

### Documentation

## v0.13.0 (2022 Oct 22)

### New features
Expand Down
4 changes: 3 additions & 1 deletion arviz/plots/traceplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ def plot_trace(
divergences = "top" if rug else "bottom"
if divergences:
try:
divergence_data = convert_to_dataset(data, group="sample_stats").diverging
divergence_data = convert_to_dataset(data, group="sample_stats").diverging.transpose(
"chain", "draw"
)
except (ValueError, AttributeError): # No sample_stats, or no `.diverging`
divergences = None

Expand Down
6 changes: 6 additions & 0 deletions arviz/tests/base_tests/test_plots_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ def test_plot_trace_invalid_varname_warning(models, kwargs):
assert axes.shape


def test_plot_trace_diverging_correctly_transposed():
idata = load_arviz_data("centered_eight")
idata.sample_stats["diverging"] = idata.sample_stats.diverging.T
plot_trace(idata, divergences="bottom")


@pytest.mark.parametrize(
"bad_kwargs", [{"var_names": ["mu", "tau"], "lines": [("mu", {}, ["hey"])]}]
)
Expand Down