summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/function_base.py12
-rw-r--r--numpy/lib/tests/test_function_base.py2
2 files changed, 7 insertions, 7 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 168623b82..6799b2a4f 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -3876,13 +3876,13 @@ def _quantile_is_valid(q):
def _lerp(a, b, t, out=None):
""" Linearly interpolate from a to b by a factor of t """
#a + (b-a)*t if t < 0.5 else b - (b-a)*(1-t)
- if t < 0.5:
- return add(a, subtract(b, a)*t, out=out)
- else:
- return subtract(b, subtract(b, a)*(1-t), out=out)
+ #if t < 0.5:
+ # return add(a, subtract(b, a)*t, out=out)
+ #else:
+ # return subtract(b, subtract(b, a)*(1-t), out=out)
# a + (b-a)*t
- #offset = subtract(b, a) * t
- #return add(a, offset, out=out)
+ offset = subtract(b, a) * t
+ return add(a, offset, out=out)
def _quantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False,
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 9ac6e94ce..de2716bf1 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -3153,7 +3153,7 @@ class TestLerp:
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)
+ assert np.isclose(np.lib.function_base._lerp(a, b, t), np.lib.function_base._lerp(b, a, (1-t)))
class TestMedian: