diff options
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index c415653e4..ea562b466 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -5,6 +5,10 @@ import decimal from fractions import Fraction import math import pytest +import hypothesis +from hypothesis.extra.numpy import arrays +import hypothesis.strategies as st + import numpy as np from numpy import ma @@ -3104,7 +3108,7 @@ class TestQuantile: np.quantile(np.arange(100.), p, interpolation="midpoint") assert_array_equal(p, p0) - def test_quantile_monotic(self): + def test_quantile_monotonic(self): # GH 14685 # test that the return value of quantile is monotonic if p0 is ordered p0 = np.arange(0, 1, 0.01) @@ -3112,6 +3116,15 @@ class TestQuantile: equals_sorted = np.sort(quantile) == quantile assert equals_sorted.all() + @hypothesis.given(arr=arrays(dtype=np.float, shape=st.integers(min_value=3, max_value=1000), + elements=st.floats(allow_infinity=False, allow_nan=False))) + def test_quantile_monotonic_hypo(self, arr): + p0 = np.arange(0, 1, 0.01) + quantile = np.quantile(arr, p0) + equals_sorted = np.sort(quantile) == quantile + assert equals_sorted.all() + + class TestMedian: def test_basic(self): |