diff options
author | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2018-02-26 09:11:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-26 09:11:31 -0500 |
commit | 8282036f0938234efab936152ad963b9ddccca83 (patch) | |
tree | c255b37b3c296f5d79a8f5b1aada93f9fb5b32f7 /numpy/lib/function_base.py | |
parent | 1ee1a4ac7f79e8c707c416f81f049fd3ac94f1e6 (diff) | |
parent | 8eccbf7df2f564e23c1bf7c9f5ee08e4b0dc6a36 (diff) | |
download | numpy-8282036f0938234efab936152ad963b9ddccca83.tar.gz |
Merge pull request #10660 from eric-wieser/0d-interp-simpler
BUG/MAINT: Remove special cases for 0d arrays in interp
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 391c47a06..504280cef 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1255,23 +1255,13 @@ def interp(x, xp, fp, left=None, right=None, period=None): interp_func = compiled_interp input_dtype = np.float64 - if period is None: - if isinstance(x, (float, int, number)): - return interp_func([x], xp, fp, left, right).item() - elif isinstance(x, np.ndarray) and x.ndim == 0: - return interp_func([x], xp, fp, left, right).item() - else: - return interp_func(x, xp, fp, left, right) - else: + if period is not None: if period == 0: raise ValueError("period must be a non-zero value") period = abs(period) left = None right = None - return_array = True - if isinstance(x, (float, int, number)): - return_array = False - x = [x] + x = np.asarray(x, dtype=np.float64) xp = np.asarray(xp, dtype=np.float64) fp = np.asarray(fp, dtype=input_dtype) @@ -1289,10 +1279,7 @@ def interp(x, xp, fp, left=None, right=None, period=None): xp = np.concatenate((xp[-1:]-period, xp, xp[0:1]+period)) fp = np.concatenate((fp[-1:], fp, fp[0:1])) - if return_array: - return interp_func(x, xp, fp, left, right) - else: - return interp_func(x, xp, fp, left, right).item() + return interp_func(x, xp, fp, left, right) def angle(z, deg=0): |