dfm / dfm/corner.py

Having title_quantiles=None when quantiles is passed without having exactly 3 elements raises a ValueError

Open
#237 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
576
Forks
234
PR merge metrics
No merged PRs in 30d

Description

Hi,

The behaviour of the title_quantiles argument that was introduced in v2.2.2 is responsible for a crash when using the following set of arguments:
show_titles=True, title_quantiles=None
and a list for quantiles that has a number of elements other than 3. In this case, according to what is written in the documentation, the value for title_quantiles is set as what is passed for quantiles, and a ValueError is raised.

In particular, this is an issue for compatibility with codes that were running with corner versions older than v2.2.2.

The error can be reproduced by slightly modifying the code from the Getting started tutorial (https://corner.readthedocs.io/en/latest/pages/quickstart/):

import corner
import numpy as np

ndim, nsamples = 2, 10000
np.random.seed(42)
samples = np.random.randn(ndim * nsamples).reshape([nsamples, ndim])
figure = corner.corner(samples, quantiles=[0.16, 0.84], 
                       show_titles=True, title_quantiles=None)

Running this code, the following error is raised:
ValueError: 'title_quantiles' must contain exactly three values; pass a length-3 list or array using the 'title_quantiles' argument

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the corner.corner entry point and reproduce the issue with the modified Getting started example using quantiles=[0.16, 0.84], show_titles=True, and title_quantiles=None. Trace how these arguments are validated and confirm that the compatibility case completes without the reported ValueError.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.