Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #6103 on branch v0.19.x (make rank filter test comparisons robust across architectures) #6106

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions skimage/filters/rank/tests/test_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ def check():
assert_array_almost_equal(expected, result)
else:
if outdt is not None:
# Avoid rounding issues comparing to expected result
result = result.astype(expected.dtype)
# Avoid rounding issues comparing to expected result.
# Take modulus first to avoid undefined behavior for
# float->uint8 conversions.
result = np.mod(result, 256.0).astype(expected.dtype)
assert_array_almost_equal(expected, result)

check()
Expand Down Expand Up @@ -147,7 +149,9 @@ def check():
datadt = np.uint8
else:
datadt = expected.dtype
result = result.astype(datadt)
# Take modulus first to avoid undefined behavior for
# float->uint8 conversions.
result = np.mod(result, 256.0).astype(datadt)
assert_array_almost_equal(expected, result)

check()
Expand Down