ENH: Return level as type int if it is very close to an integer#128
Merged
Leengit merged 1 commit intoDigitalSlideArchive:masterfrom Apr 23, 2023
Merged
ENH: Return level as type int if it is very close to an integer#128Leengit merged 1 commit intoDigitalSlideArchive:masterfrom
level as type int if it is very close to an integer#128Leengit merged 1 commit intoDigitalSlideArchive:masterfrom
Conversation
manthey
reviewed
Apr 21, 2023
histomics_stream/configure.py
Outdated
|
|
||
| slide["level"] = level | ||
| int_level = int(level + 0.5) | ||
| slide["level"] = int_level if abs(level - int_level) < 1e-6 else level |
Contributor
There was a problem hiding this comment.
For what it is worth, I think we use 1e-4 as the threshold in geojs.
Collaborator
Author
There was a problem hiding this comment.
I just force-pushed with 1e-4 as the threshold. I also put a math.floor call in there because it appears that Python's int cast rounds towards zero rather than rounding towards negative infinity.
Contributor
There was a problem hiding this comment.
I probably would have used int(round(value)), but that also moves values that have exactly .5 as the fraction toward zero.
Collaborator
Author
There was a problem hiding this comment.
We reject int_level if it is farther than 1e-4 from the returned level, so what happens with 0.5 won't affect us here. I've gone with int(round(level)) with this latest force push.
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.
When
large_imageis asked to return tiles with an"exact"magnification it may end up using alevel(in the sense thatlarge_imagedefines it) that is a non-integer. (Also, a non-integer value oflevelmight occur if the stored"native"magnifications are different by something other than powers of two.) However, if that level is within1e-6of an integer we will return it as typeintrather than typefloat.@cooperlab if it would be better to round to the integer value but leave it as type
float, please let me know.Closes #95.