Repository navigation
BUG: Handle large numbers and edge creations on histogram. - #31496
Open
JosephMehdiyev wants to merge 3 commits into
Open
JosephMehdiyev wants to merge 3 commits into
JosephMehdiyev wants to merge 3 commits into
Conversation
Contributor
Author
|
hmmm, this PR looks simple enough. I was checking and closing my old PRs as I was not planning to work on them anymore, but this one looks fine and simple? If any maintainers think otherwise be welcome to close this, otherwise I'll forget this PR again haha |
Contributor
|
There are still some cases to be handled: for histogramdd the bin count is not passed. E.g. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR summary
Fixes #8627 (wrongly tagged another issue)
If I am understanding correctly, prior to this PR,
np.linspacewould give equal edges because of the distances between float64 types i.e2**52+0.5couldn't be represented as a proper float and as a result edges would be equal and monotonic check would fail. To make sure this never happens, the_outer_bin_edgeshould use the number of bins and the spacing of the type of the edge.this PR handles all 3 histogram functions.
Other comments
This is the first time I have worked on an issue about large floats/numbers, so be warned.
There are specific cases like
np.histogram([2**53,2**53+2])which is not quite possible to fix,unless bin numbers are changed undirectly. There is a issue about better default bin number selection which will fix this.In some cases with big data values with very low spread, the similar issue I think will occur and linspace may generate equal sized edges. The first workaround would be to chose smaller bin sizes or somewhere in logic we could add spacing like this PR's case. But this is somewhat unrelated to the main issue so I might open another PR for that
AI Disclosure
Claude used to review the code.