Skip to content

Avoid overflow in linspace test #2451

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

Merged
merged 3 commits into from
May 15, 2025
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
7 changes: 5 additions & 2 deletions dpnp/tests/third_party/cupy/creation_tests/test_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,13 @@ def test_linspace_mixed_start_stop2(self, xp, dtype_range, dtype_out):
# TODO (ev-br): np 2.0: check if can re-enable float16
# TODO (ev-br): np 2.0: had to bump the default rtol on Windows
# and numpy 1.26+weak promotion from 0 to 5e-6
if xp.dtype(dtype_range).kind in "u":
if xp.dtype(dtype_range).kind == "u":
# to avoid overflow, limit `val` to be smaller
# than xp.iinfo(dtype).max
if dtype_range in [xp.uint8, xp.uint16] or dtype_out == xp.uint8:
if dtype_range in [xp.uint8, xp.uint16] or dtype_out in [
xp.int8,
xp.uint8,
]:
val = 125
else:
val = 160
Expand Down
Loading