summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/tests/test_dtype.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py
index 2246a4802..34d418926 100644
--- a/numpy/core/tests/test_dtype.py
+++ b/numpy/core/tests/test_dtype.py
@@ -1097,12 +1097,12 @@ class TestPromotion:
(2**32-1, np.complex128),
(np.float16(2), np.complex64),
(np.float32(2), np.complex64),
- (np.float128(2), np.complex64),
+ (np.longdouble(2), np.complex64),
(np.nextafter(np.longdouble(1.7e308), 0.), np.complex128),
(np.longdouble(1.7e308), np.clongdouble),
])
- def test_complex_value_based(self, other, expected):
- # This would change if we modfiy the value based promotion
+ def test_complex_other_value_based(self, other, expected):
+ # This would change if we modify the value based promotion
min_complex = np.dtype(np.complex64)
res = np.result_type(other, min_complex)
@@ -1111,6 +1111,24 @@ class TestPromotion:
res = np.minimum(other, np.ones(3, dtype=min_complex)).dtype
assert res == expected
+ @pytest.mark.parametrize(["other", "expected"],
+ [(np.bool_, np.complex128),
+ (np.int64, np.complex128),
+ (np.float16, np.complex64),
+ (np.float32, np.complex64),
+ (np.float64, np.complex128),
+ (np.longdouble, np.clongdouble),
+ ])
+ def test_complex_scalar_value_based(self, other, expected):
+ # This would change if we modify the value based promotion
+ complex_scalar = 1j
+
+ res = np.result_type(other, complex_scalar)
+ assert res == expected
+ # Check the same for a simple ufunc call that uses the same logic:
+ res = np.minimum(np.ones(3, dtype=other), complex_scalar).dtype
+ assert res == expected
+
@pytest.mark.parametrize(["dtypes", "expected"],
[([np.uint16, np.int16, np.float16], np.float32),
([np.uint16, np.int8, np.float16], np.float32),