diff options
| author | Sebastian Berg <sebastian@sipsolutions.net> | 2022-09-09 11:47:12 +0200 |
|---|---|---|
| committer | Sebastian Berg <sebastianb@nvidia.com> | 2022-10-12 10:41:40 +0200 |
| commit | c4f1419c0484e2772f181210bfc7a9b86267a5d3 (patch) | |
| tree | 38f2071439e17ec9bc4a4194bb0a9167327620db /numpy | |
| parent | d47b09c047c2128e820f4d4f27f10b3fd7d8b05b (diff) | |
| download | numpy-c4f1419c0484e2772f181210bfc7a9b86267a5d3.tar.gz | |
TST: Rebustify NEP 50 integer tests for windows and 32bit linux
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/tests/test_nep50_promotions.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/core/tests/test_nep50_promotions.py b/numpy/core/tests/test_nep50_promotions.py index 168b67a86..aec3b1a61 100644 --- a/numpy/core/tests/test_nep50_promotions.py +++ b/numpy/core/tests/test_nep50_promotions.py @@ -98,6 +98,16 @@ def test_nep50_weak_integers_with_inexact(dtype): with pytest.raises(OverflowError): np.array(1, dtype=dtype) + too_big_int else: + # NumPy uses (or used) `int -> string -> longdouble` for the + # conversion. But Python may refuse `str(int)` for huge ints. + # In that case, RuntimeWarning would be correct, but conversion + # fails earlier (seems to happen on 32bit linux, possibly only debug). + if dtype in "gG": + try: + str(too_big_int) + except ValueError: + pytest.skip("`huge_int -> string -> longdouble` failed") + # Otherwise, we overflow to infinity: with pytest.warns(RuntimeWarning): res = scalar_type(1) + too_big_int @@ -105,7 +115,10 @@ def test_nep50_weak_integers_with_inexact(dtype): assert res == np.inf with pytest.warns(RuntimeWarning): - res = np.array(1, dtype=dtype) + too_big_int + # We force the dtype here, since windows may otherwise pick the + # double instead of the longdouble loop. That leads to slightly + # different results (conversion of the int fails as above). + res = np.add(np.array(1, dtype=dtype), too_big_int, dtype=dtype) assert res.dtype == dtype assert res == np.inf |
