dfm / dfm/corner.py

Error when specifying `truths` for 1-D data

Open
#285 0 comments 1 reaction 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

Calling corner.corner with 1-dimensional data and truths leads to a TypeError, see the traceback and example below.

As far as I can tell, this is new to v2.2.3 and works in previous versions.

Traceback

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mjwill/.conda/envs/nessai/lib/python3.10/site-packages/corner/corner.py", line 280, in corner
    return arviz_corner(
  File "/home/mjwill/.conda/envs/nessai/lib/python3.10/site-packages/corner/arviz_corner.py", line 136, in arviz_corner
    fig = corner_impl(
  File "/home/mjwill/.conda/envs/nessai/lib/python3.10/site-packages/corner/core.py", line 457, in corner_impl
    overplot_lines(fig, truths, reverse=reverse, color=truth_color)
  File "/home/mjwill/.conda/envs/nessai/lib/python3.10/site-packages/corner/core.py", line 847, in overplot_lines
    axes[k1, k1].axvline(xs[k1], **kwargs)
TypeError: 'AxesSubplot' object is not subscriptable

Minimum example


import corner
import numpy as np
rng = np.random.default_rng()
data = rng.standard_normal(size=(1000, 1))
corner.corner(data, truths=[0])

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 with the minimum example in the issue and inspect corner/core.py, especially overplot_lines, where the traceback reports the failure. Confirm that corner.corner accepts one-dimensional data with truths=[0] without raising TypeError and still produces the truth marker.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.