diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2010-05-07 02:25:08 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2010-05-07 02:25:08 +0000 |
commit | b66a200a4a1e98f1955c8a774e4ebfb4588dab5b (patch) | |
tree | 26252c2c011e0f6a168c63e5c38537d36672a8b3 /numpy/lib/function_base.py | |
parent | 20757e2fe36792e67613e3231e10eaa109660fea (diff) | |
download | numpy-b66a200a4a1e98f1955c8a774e4ebfb4588dab5b.tar.gz |
BUG: Make interp handle zero dimensional ndarrays as interpolation
points. Add some tests for interp. Fixes ticket #1177.
unc_api.txt.tmp
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 3f293ae4c..680103924 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -55,7 +55,7 @@ def histogram(a, bins=10, range=None, normed=False, weights=None): range : (float, float), optional The lower and upper range of the bins. If not provided, range is simply ``(a.min(), a.max())``. Values outside the range are - ignored. + ignored. normed : bool, optional If False, the result will contain the number of samples in each bin. If True, the result is the value of the @@ -68,7 +68,7 @@ def histogram(a, bins=10, range=None, normed=False, weights=None): only contributes its associated weight towards the bin count (instead of 1). If `normed` is True, the weights are normalized, so that the integral of the density over the range remains 1 - + Returns ------- hist : array @@ -76,7 +76,7 @@ def histogram(a, bins=10, range=None, normed=False, weights=None): description of the possible semantics. bin_edges : array of dtype float Return the bin edges ``(length(hist)+1)``. - + See Also -------- @@ -112,7 +112,7 @@ def histogram(a, bins=10, range=None, normed=False, weights=None): 1.0 """ - + a = asarray(a) if weights is not None: weights = asarray(weights) @@ -985,6 +985,8 @@ def interp(x, xp, fp, left=None, right=None): """ if isinstance(x, (float, int, number)): return compiled_interp([x], xp, fp, left, right).item() + elif isinstance(x, np.ndarray) and x.ndim == 0: + return compiled_interp([x], xp, fp, left, right).item() else: return compiled_interp(x, xp, fp, left, right) @@ -2043,7 +2045,7 @@ def blackman(M): >>> plt.xlabel("Sample") <matplotlib.text.Text object at 0x...> >>> plt.show() - + >>> plt.figure() <matplotlib.figure.Figure object at 0x...> >>> A = fft(window, 2048) / 25.5 @@ -2152,7 +2154,7 @@ def bartlett(M): >>> plt.xlabel("Sample") <matplotlib.text.Text object at 0x...> >>> plt.show() - + >>> plt.figure() <matplotlib.figure.Figure object at 0x...> >>> A = fft(window, 2048) / 25.5 |