Skip to content

Accept array-like samples in hist2d - #349

Open
antonsoo wants to merge 1 commit into
dfm:mainfrom
antonsoo:fix/hist2d-array-like-inputs
Open

antonsoo wants to merge 1 commit into
dfm:mainfrom
antonsoo:fix/hist2d-array-like-inputs

Conversation

@antonsoo

Copy link
Copy Markdown

hist2d documents array-like samples, but Python lists fail before plotting:

import corner

corner.hist2d([1., 2., 3., 4.], [4., 2., 1., 3.],
              bins=3, plot_contours=False, quiet=True)
print('complete')
# Before: AttributeError: 'list' object has no attribute 'min'
# After: complete

Convert both inputs with np.atleast_1d before computing ranges or flattening them. NumPy arrays keep their existing path; list and tuple inputs now support both inferred and explicit ranges.

Tests compare density values, plotted paths and limits with the same NumPy samples. The complete suite passes on Python 3.12 and 3.14, with the existing skip, and all pre-commit hooks pass. List/tuple inputs from archived posterior draws also produce identical complete artists and rendered images with linear/log axes, weights and filled contours.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant