diff options
author | Tobias Pitters <tobias.pitters@gmail.com> | 2020-05-26 21:12:05 +0200 |
---|---|---|
committer | Tobias Pitters <tobias.pitters@gmail.com> | 2020-05-27 19:35:59 +0200 |
commit | 708798bf82299081b040f672173956ac8a39e877 (patch) | |
tree | 2871b78acb729a336d398b568cc86c2aa38b7f4f /numpy/lib/tests/test_function_base.py | |
parent | 54de868a1a37b182a94f2d521fe2c695bf19ddea (diff) | |
download | numpy-708798bf82299081b040f672173956ac8a39e877.tar.gz |
remove pdb; add hypothesis tests for monotony, boundedness and symmetry of lerp
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index ea562b466..9ac6e94ce 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -3125,6 +3125,37 @@ class TestQuantile: assert equals_sorted.all() +class TestLerp: + @hypothesis.given(t0=st.floats(allow_nan=False, allow_infinity=False, + min_value=0, max_value=1), + t1=st.floats(allow_nan=False, allow_infinity=False, + min_value=0, max_value=1), + a=st.floats(allow_nan=False, allow_infinity=False, + width=32), + b= st.floats(allow_nan=False, allow_infinity=False, + width=32)) + def test_lerp_monotonic(self, t0, t1, a, b): + assert (np.lib.function_base._lerp(a, b, t1) - + np.lib.function_base._lerp(a, b, t0)) * (b - a) * (t1 - t0) >= 0 + + @hypothesis.given(t=st.floats(allow_nan=False, allow_infinity=False, + min_value=0, max_value=1), + a=st.floats(allow_nan=False, allow_infinity=False), + b=st.floats(allow_nan=False, allow_infinity=False)) + def test_lerp_bounded(self, t, a, b): + if a <= b: + assert a <= np.lib.function_base._lerp(a, b, t) <= b + else: + assert b <= np.lib.function_base._lerp(a, b, t) <= a + + @hypothesis.given(t=st.floats(allow_nan=False, allow_infinity=False, + min_value=0, max_value=1), + a=st.floats(allow_nan=False, allow_infinity=False), + b=st.floats(allow_nan=False, allow_infinity=False)) + def test_lerp_symmetric(self, t, a, b): + assert np.lib.function_base._lerp(a, b, t) == np.lib.function_base._lerp(b, a, t) + + class TestMedian: def test_basic(self): |