Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index out of bounds for hist() on negative values #35

Closed
audatic-henning opened this issue Sep 11, 2020 · 3 comments · Fixed by #36
Closed

Index out of bounds for hist() on negative values #35

audatic-henning opened this issue Sep 11, 2020 · 3 comments · Fixed by #36

Comments

@audatic-henning
Copy link

Negative values in histogram sometimes seem to lead to negative bin indices that can underflow (and shouldnt be there in the first place).

I believe the fix is in plotille/_util in hist() around line 85
to change the computation of x_idx to

        x_idx = max(min(bins - 1, int(delta // xwidth)), 0)

(the max is new). Alas I don't have time to thoroughly test and/or create a PR right now, maybe someone else can pick it up

@audatic-henning
Copy link
Author

I should add I'm using numpy arrays of int16s, seems even with the fix there is thus an issue with overflow/underflow

@tammoippen
Copy link
Owner

@audatic-henning Should be fixed in v3.7.2 . Can you please verify.

@audatic-henning
Copy link
Author

Solved it for me, thanks a lot for the quick solution!

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 a pull request may close this issue.

2 participants