corner.py
corner.py copied to clipboard
Crash with float-type bins
In Python 2.7, NumPy 1.14.0, and corner 1.0.2, crashes with the error "TypeError: bins
must be an integer, a string, or an array". This is probably related to https://github.com/numpy/numpy/issues/8072 -- because bins are defined in corner.py as floats.
Obvious fix would be to cast the bins to type int before drawing the histograms.
Hi Ian, Thanks! Can you send a snippet that reproduces this error and the text of the exact error message and traceback?
I have just run into this same problem. I have fixed it by changing
n, _, _ = ax.hist(x, bins=bins[i], weights=weights, range=range[i], **hist_kwargs)
to
n, _, _ = ax.hist(x, bins=int(bins[i]), weights=weights, range=range[i], **hist_kwargs)
on this line.
Hi, That's not really a good solution because the elements of bins
can also be arrays of bin edges. When you're finding that this fails, are you providing your own bin edges or is corner somehow selecting floating point edges itself? If the former, you cans solve it as:
bins = np.array([...], dtype=float)
corner.corner(samples, bins=bins.astype(int))
I see. I did not supply any bins or bin edges - everything was left to defaults.
Interesting! Can you provide a simple code snippet that reproduces the error?
On Fri, Jan 11, 2019 at 9:25 AM Earl Patrick Bellinger < [email protected]> wrote:
I see. I did not supply any bins or bin edges - everything was left to defaults.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_dfm_corner.py_issues_111-23issuecomment-2D453592821&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=AvKCBU-zyph1qdf6NaatMQ&m=6OuOvY-L3xGv54qkZfx-KosfIW-M_6QO4QmduPQw3E0&s=2crq6tk0183GXdGg0BaXEcR6hzEeFz6339QxIy_l5DI&e=, or mute the thread https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AAVYSulXPWwMbhQN31L-5FEByJtXLu0-5F6Xks5vCMjsgaJpZM4RvvkZ&d=DwMCaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=AvKCBU-zyph1qdf6NaatMQ&m=6OuOvY-L3xGv54qkZfx-KosfIW-M_6QO4QmduPQw3E0&s=j2vL3X_5yR3KaLAUts-j4c3R2DpO5M7iPTV-z2SXyV4&e= .
-- Dan Foreman-Mackey Associate Research Scientist Flatiron Institute http://dfm.io