[BUG] fix rounding issue in uv_to_color() #2336
Merged
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.
Hi Mike,
I discovered an index out of bounds error in the
to_color()
function when converting TextureVisual to ColorVisuals.The issue occurs in the
uv_to_color()
function here:The modulus (
%
) operation on float values can cause index out of bounds errors when rounding values near the bounds. For example:uv[i, 0] == -26.05739974975586
andimage.width == 456
x[i] == 455.883113861084
after modulus operationx = (uv[:, 0] * (image.width - 1)) % image.width
x.round().astype(np.int64) == 456
[0, 455]
, causing the errorI have fixed this issue in this pull request, please let me know if you have any further concerns!
Best,
Zeyu