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

Proposed fix for title errorbars/quantiles bug #193

Merged
merged 4 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
updating tests
  • Loading branch information
dfm committed Feb 22, 2022
commit 8524c4e04e45f454d64bad37ef8b91578ef31364
9 changes: 5 additions & 4 deletions src/corner/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ def corner_impl(
# a default for when quantiles not supplied.
title_quantiles = [0.16, 0.5, 0.84]

assert len(title_quantiles) == 3, (
"title_quantiles must contain three values -- "
"please pass a length-3 list or array using the title_quantiles kwarg"
)
if show_titles and len(title_quantiles) != 3:
raise ValueError(
"'title_quantiles' must contain exactly three values; "
"pass a length-3 list or array using the 'title_quantiles' argument"
)

# Deal with 1D sample lists.
xs = _parse_input(xs)
Expand Down
34 changes: 31 additions & 3 deletions tests/test_corner.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,39 @@ def test_labels():
def test_quantiles():
_run_corner(quantiles=[0.16, 0.5, 0.84])


@image_comparison(
baseline_images=["quantiles"], remove_text=False extensions=["png"]
baseline_images=["title_quantiles"], remove_text=False, extensions=["png"]
)
def test_quantiles():
_run_corner(quantiles=[0.16, 0.5, 0.84], title_quantiles=None)
def test_title_quantiles():
_run_corner(
quantiles=[0.16, 0.5, 0.84],
title_quantiles=[0.05, 0.5, 0.95],
show_titles=True,
)


@image_comparison(
baseline_images=["title_quantiles_default"],
remove_text=False,
extensions=["png"],
)
def test_title_quantiles_default():
_run_corner(quantiles=[0.16, 0.5, 0.84], show_titles=True)


@image_comparison(
baseline_images=["title_quantiles_raises"],
remove_text=False,
extensions=["png"],
)
def test_title_quantiles_raises():
with pytest.raises(ValueError):
_run_corner(quantiles=[0.05, 0.16, 0.5, 0.84, 0.95], show_titles=True)

# This one shouldn't raise since show_titles isn't provided
_run_corner(quantiles=[0.05, 0.16, 0.5, 0.84, 0.95])


@image_comparison(
baseline_images=["color"], remove_text=True, extensions=["png"]
Expand Down