diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2017-12-31 08:13:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-31 08:13:02 -0700 |
commit | 7255987a11c8b90ff525ad178419b22508164e23 (patch) | |
tree | d45224f4b57bbde6c12b1dfab58f2b82c82b0820 /numpy/core/fromnumeric.py | |
parent | 5f281116066493ead7f16e3e6dcd7bedbba48b46 (diff) | |
parent | 317ff845c7fc92bcab9e713e38f24cc898223f70 (diff) | |
download | numpy-7255987a11c8b90ff525ad178419b22508164e23.tar.gz |
Merge pull request #10298 from eric-wieser/digitize-docs
DOC: Explain np.digitize and np.searchsorted more clearly
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r-- | numpy/core/fromnumeric.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 61ab322df..8203684e9 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1076,6 +1076,15 @@ def searchsorted(a, v, side='left', sorter=None): corresponding elements in `v` were inserted before the indices, the order of `a` would be preserved. + Assuming that `a` is sorted: + + ====== ============================ + `side` returned index `i` satisfies + ====== ============================ + left ``a[i-1] < v <= a[i]`` + right ``a[i-1] <= v < a[i]`` + ====== ============================ + Parameters ---------- a : 1-D array_like @@ -1111,6 +1120,10 @@ def searchsorted(a, v, side='left', sorter=None): As of NumPy 1.4.0 `searchsorted` works with real/complex arrays containing `nan` values. The enhanced sort order is documented in `sort`. + This function is a faster version of the builtin python `bisect.bisect_left` + (``side='left'``) and `bisect.bisect_right` (``side='right'``) functions, + which is also vectorized in the `v` argument. + Examples -------- >>> np.searchsorted([1,2,3,4,5], 3) |