diff options
author | abel <aoun@cerfacs.fr> | 2021-11-09 17:35:03 +0100 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2021-11-09 14:41:57 -0600 |
commit | 53e3df3c99a26791cc07e2ea1570e87643fdf7e0 (patch) | |
tree | a7ddc36273f9598cc86dc5bda565ece45ad83708 /numpy/lib/tests/test_function_base.py | |
parent | 6cd68755c6fd0686dd57a9daec43d8aa09d15c3e (diff) | |
download | numpy-53e3df3c99a26791cc07e2ea1570e87643fdf7e0.tar.gz |
TST: Add test for max ulp in default quantile calculation
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index d5fa012f1..1c274afae 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -3356,6 +3356,14 @@ class TestPercentile: class TestQuantile: # most of this is already tested by TestPercentile + def test_max_ulp(self): + x = [0.0, 0.2, 0.4] + a = np.quantile(x, 0.45) + # The default linear method would result in 0 + 0.2 * (0.45/2) = 0.18. + # 0.18 is not exactly representable and the formula leads to a 1 ULP + # different result. Ensure it is this exact within 1 ULP, see gh-20331. + np.testing.assert_array_max_ulp(a, 0.18, maxulp=1) + def test_basic(self): x = np.arange(8) * 0.5 assert_equal(np.quantile(x, 0), 0.) |