summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index bdcbef91d..b6ea12158 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -2954,11 +2954,11 @@ class TestPercentile:
H_F_TYPE_CODES = [(int_type, np.float64)
for int_type in np.typecodes["AllInteger"]
- ] + [(np.float16, np.float64),
- (np.float32, np.float64),
+ ] + [(np.float16, np.float16),
+ (np.float32, np.float32),
(np.float64, np.float64),
(np.longdouble, np.longdouble),
- (np.complex64, np.complex128),
+ (np.complex64, np.complex64),
(np.complex128, np.complex128),
(np.clongdouble, np.clongdouble),
(np.dtype("O"), np.float64)]
@@ -2980,10 +2980,15 @@ class TestPercentile:
expected,
input_dtype,
expected_dtype):
+ expected_dtype = np.dtype(expected_dtype)
+ if np.get_promotion_state() == "legacy":
+ expected_dtype = np.promote_types(expected_dtype, np.float64)
+
arr = np.asarray([15.0, 20.0, 35.0, 40.0, 50.0], dtype=input_dtype)
actual = np.percentile(arr, 40.0, method=method)
- np.testing.assert_almost_equal(actual, expected, 14)
+ np.testing.assert_almost_equal(
+ actual, expected_dtype.type(expected), 14)
if method in ["inverted_cdf", "closest_observation"]:
if input_dtype == "O":