summaryrefslogtreecommitdiff
path: root/numpy/core/tests
diff options
context:
space:
mode:
authorSebastian Berg <sebastianb@nvidia.com>2023-05-15 17:11:06 +0200
committerSebastian Berg <sebastianb@nvidia.com>2023-05-15 17:11:06 +0200
commit626d32fc47a9803e706168ea2d72d3584a4696bd (patch)
tree6f67dfb195eaac7bfdd197a7c1b2d2623a9eca9b /numpy/core/tests
parent21602a8b1673a7b468d032ef19c20c53ac15c0b9 (diff)
downloadnumpy-626d32fc47a9803e706168ea2d72d3584a4696bd.tar.gz
MAINT: Address Marten's review
Diffstat (limited to 'numpy/core/tests')
-rw-r--r--numpy/core/tests/test_nep50_promotions.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/numpy/core/tests/test_nep50_promotions.py b/numpy/core/tests/test_nep50_promotions.py
index 0b297e0f7..7d52c5089 100644
--- a/numpy/core/tests/test_nep50_promotions.py
+++ b/numpy/core/tests/test_nep50_promotions.py
@@ -195,7 +195,8 @@ def test_nep50_with_axisconcatenator():
@pytest.mark.parametrize("state", ["weak", "weak_and_warn"])
def test_nep50_huge_integers(ufunc, state):
# Very large integers are complicated, because they go to uint64 or
- # object dtype. When mixed with another uint64 that should
+ # object dtype. This tests covers a few possible paths (some of which
+ # cannot give the NEP 50 warnings).
np._set_promotion_state(state)
with pytest.raises(OverflowError):
@@ -220,3 +221,14 @@ def test_nep50_huge_integers(ufunc, state):
assert res.dtype == np.uint64
assert res == ufunc(1, 2**63, dtype=object)
+
+ # The following paths fail to warn correctly about the change:
+ with pytest.raises(OverflowError):
+ ufunc(np.int64(1), 2**63) # np.array(2**63) would go to uint
+
+ with pytest.raises(OverflowError):
+ ufunc(np.int64(1), 2**100) # np.array(2**100) would go to object
+
+ # This would go to object and thus a Python float, not a NumPy one:
+ res = ufunc(1.0, 2**100)
+ assert isinstance(res, np.float64)