Merged
Conversation
msmttchr
reviewed
Nov 9, 2021
| quantization_limit = (mn+mx) * 1.5e-15 # +/-10 discrete steps of double resolution | ||
| if mx-mn < 2*quantization_limit: | ||
| mn -= quantization_limit | ||
| mx += quantization_limit |
Contributor
There was a problem hiding this comment.
It looks good to me. Thanks. I just have a very minor point: regarding the comment approx. eps, stands for approximated double resolution ?
Contributor
Author
There was a problem hiding this comment.
Yes, numpy seems to call it that. I think C spells it out as epsilon, typically.
https://numpy.org/doc/stable/reference/generated/numpy.finfo.html
According to that page: eps = 2**-52, approximately 2.22e-16.
But there is no real benefit to being ultra-accurate here; I am just trying to explain the magic cutoff value.
Member
|
thanks for the PR @NilsNemitz, merging! |
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.
This is meant to address #2056, where the vertical axis collapses when a list of large, constant values is plotted.
The reason for this is that the default 1.0 span of the auto-scaling eventually becomes smaller than the effective (~3e-16) resolution of a double float, and the range calculations break down.
This PR sets the minimum displayed range to 6E-15 of the center value, which makes sure that at least 20 quantization steps are on screen. At this level, the errors become obvious, but the plot remains visible, and the axis manages to calculate ticks and labels.
For values < 1.6e+14, the behavior should be unchanged, except that there is now a hard lower limit on the plot range: It is no longer possible to deliberately collapse the axis range to zero. However, I could not come up with a good reason to do so.
Here is some code to play around with, based on the report in #2056:
Closes #2056, I hope.