diff --git a/src/corner/core.py b/src/corner/core.py index 050a600..b529c8c 100644 --- a/src/corner/core.py +++ b/src/corner/core.py @@ -71,9 +71,12 @@ def corner_impl( if titles is None: titles = labels - # deal with title quantiles so they much quantiles unless desired otherwise + # If title_quantiles is not supplied, provide the + # value from quantiles if and only len (quantiles) + # is 3, otherwise fall back to default [0.16, 0.5, 0.84] + # value if title_quantiles is None: - if len(quantiles) > 0: + if len(quantiles) == 3: title_quantiles = quantiles else: # a default for when quantiles not supplied. diff --git a/src/corner/corner.py b/src/corner/corner.py index e4f54ad..ed367de 100644 --- a/src/corner/corner.py +++ b/src/corner/corner.py @@ -140,13 +140,15 @@ def corner( uses labels as titles. show_titles : bool - Displays a title above each 1-D histogram showing the 0.5 quantile - with the upper and lower errors supplied by the quantiles argument. + Displays a title above each 1-D histogram showing the middle value, + lower and upper error as specified by the quantiles values provided + in `title_quantiles`. title_quantiles : iterable A list of 3 fractional quantiles to show as the the upper and lower - errors. If `None` (default), inherit the values from quantiles, unless - quantiles is `None`, in which case it defaults to [0.16,0.5,0.84] + errors. If `None` (default), and if `quantiles` has exactly three + element, inherit the values from `quantiles`. Otherwise, it defaults + to [0.16,0.5,0.84] title_fmt : string The format string for the quantiles given in titles. If you explicitly diff --git a/tests/test_corner.py b/tests/test_corner.py index 6130719..639ddc6 100644 --- a/tests/test_corner.py +++ b/tests/test_corner.py @@ -115,12 +115,19 @@ def test_title_quantiles_default(): ) 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) + _run_corner( + title_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]) +def test_len_quantiles(): + # This test should not raise an error, as title_quantile should default to [0.16, 0.5, 0.84] + _run_corner(quantiles=[0.05, 0.16, 0.5, 0.84, 0.95], show_titles=True) + + @image_comparison( baseline_images=["color"], remove_text=True, extensions=["png"] )