diff options
author | Tobias Pitters <tobias.pitters@gmail.com> | 2020-05-26 21:25:28 +0200 |
---|---|---|
committer | Tobias Pitters <tobias.pitters@gmail.com> | 2020-05-27 19:35:59 +0200 |
commit | bf65d6bd293205dda748115db897b14d3d2ececf (patch) | |
tree | 584c2d1d10b5458e77eb92c71835ddef5923718e /numpy/lib/function_base.py | |
parent | 2ffcb119c0235ee7b5c169cae65fcac44064b35a (diff) | |
download | numpy-bf65d6bd293205dda748115db897b14d3d2ececf.tar.gz |
use symmetric lerp function
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 6799b2a4f..f56a8844e 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -3875,14 +3875,10 @@ 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) - # a + (b-a)*t - offset = subtract(b, a) * t - return add(a, offset, 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) def _quantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False, |