summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorCloseChoice <tobias.pitters@gmx.de>2020-05-21 12:29:57 +0200
committerTobias Pitters <tobias.pitters@gmail.com>2020-05-27 19:35:59 +0200
commit54de868a1a37b182a94f2d521fe2c695bf19ddea (patch)
tree4e44a60107cbded801cee243d8d5237b92eeee46 /numpy/lib/tests/test_function_base.py
parent3b0516aded2f0ebc09511db63978c1f1a2445a43 (diff)
downloadnumpy-54de868a1a37b182a94f2d521fe2c695bf19ddea.tar.gz
add hypothesis test, fix bug of non-monotonic ordering of quantile function
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py15
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):