Skip to content

Commit 53e3df3

Browse files
bzahseberg
authored andcommitted
TST: Add test for max ulp in default quantile calculation
1 parent 6cd6875 commit 53e3df3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

numpy/lib/tests/test_function_base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3356,6 +3356,14 @@ def test_nan_q(self):
33563356
class TestQuantile:
33573357
# most of this is already tested by TestPercentile
33583358

3359+
def test_max_ulp(self):
3360+
x = [0.0, 0.2, 0.4]
3361+
a = np.quantile(x, 0.45)
3362+
# The default linear method would result in 0 + 0.2 * (0.45/2) = 0.18.
3363+
# 0.18 is not exactly representable and the formula leads to a 1 ULP
3364+
# different result. Ensure it is this exact within 1 ULP, see gh-20331.
3365+
np.testing.assert_array_max_ulp(a, 0.18, maxulp=1)
3366+
33593367
def test_basic(self):
33603368
x = np.arange(8) * 0.5
33613369
assert_equal(np.quantile(x, 0), 0.)

0 commit comments

Comments
 (0)