[canvas-] fix division by zero when col's only value is a large float #2884
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.
When plotting a graph, the plotter tries to prevent
xmin == xmax
by expanding the range. It adds 1 toxmax
in that situation. (We ran into this problem before in #1673.) But that fails for large floats, because adding 1 leaves the number unchanged, as inx=2**53; float(x) == float(x + 1)
. (Becausemath.ulp(2**53)
is 2.0.)Example, when plotting the first 2 or last 2 lines of this data with
.
:visidata 3.3 gives
ZeroDivisionError: float division by zero
because the width or height of the box is zero whenxmin == xmax
orymin == ymax
:and
This PR handles the case of such large floats.