summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2021-04-19 21:51:47 -0500
committerSebastian Berg <sebastian@sipsolutions.net>2021-05-12 15:33:34 -0700
commit6fd0f97b436c162ba4b613c7dff665d56d351f84 (patch)
tree1c5960816f601770757d0c05822c8ef601088e69 /numpy
parent834b1184c1f609a4e9ba06c55ea64ba882e4cdc1 (diff)
downloadnumpy-6fd0f97b436c162ba4b613c7dff665d56d351f84.tar.gz
TST: Fixup tests and make sure complex is also the value
Diffstat (limited to 'numpy')
-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),