diff options
author | Travis E. Oliphant <teoliphant@gmail.com> | 2012-04-04 14:02:44 -0700 |
---|---|---|
committer | Travis E. Oliphant <teoliphant@gmail.com> | 2012-04-04 14:02:44 -0700 |
commit | b35eaccfae6ec00310e7203a310e3de7b6b8018d (patch) | |
tree | 5362d2b365d79ec01868662a1550887a8570d8d9 /numpy/add_newdocs.py | |
parent | 168a55e66f992c9dbbb991f9a729fb04a6437c17 (diff) | |
parent | 54746848f313ba1ee22a812e8b500d4bcc334910 (diff) | |
download | numpy-b35eaccfae6ec00310e7203a310e3de7b6b8018d.tar.gz |
Merge pull request #245 from jseabold/digitize-open-right
ENH: Give digitize left or right open interval option
Diffstat (limited to 'numpy/add_newdocs.py')
-rw-r--r-- | numpy/add_newdocs.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index d6bd881cc..6c6488547 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -4865,14 +4865,17 @@ add_newdoc('numpy.core.umath', 'seterrobj', add_newdoc('numpy.lib._compiled_base', 'digitize', """ - digitize(x, bins) + digitize(x, bins, right=False) Return the indices of the bins to which each value in input array belongs. Each index ``i`` returned is such that ``bins[i-1] <= x < bins[i]`` if `bins` is monotonically increasing, or ``bins[i-1] > x >= bins[i]`` if `bins` is monotonically decreasing. If values in `x` are beyond the - bounds of `bins`, 0 or ``len(bins)`` is returned as appropriate. + bounds of `bins`, 0 or ``len(bins)`` is returned as appropriate. If right + is True, then the right bin is closed so that the index ``i`` is such + that ``bins[i-1] < x <= bins[i]`` or bins[i-1] >= x > bins[i]`` if `bins` + is monotonically increasing or decreasing, respectively. Parameters ---------- @@ -4880,6 +4883,12 @@ add_newdoc('numpy.lib._compiled_base', 'digitize', Input array to be binned. It has to be 1-dimensional. bins : array_like Array of bins. It has to be 1-dimensional and monotonic. + right : bool, optional + Indicating whether the intervals include the right or the left bin + edge. Default behavior is (right==False) indicating that the interval + does not include the right edge. The left bin and is open in this + case. Ie., bins[i-1] <= x < bins[i] is the default behavior for + monotonically increasing bins. Returns ------- @@ -4918,6 +4927,12 @@ add_newdoc('numpy.lib._compiled_base', 'digitize', 2.5 <= 3.0 < 4.0 1.0 <= 1.6 < 2.5 + >>> x = np.array([1.2, 10.0, 12.4, 15.5, 20.]) + >>> bins = np.array([0,5,10,15,20]) + >>> np.digitize(x,bins,right=True) + array([1, 2, 3, 4, 4]) + >>> np.digitize(x,bins,right=False) + array([1, 3, 3, 4, 5]) """) add_newdoc('numpy.lib._compiled_base', 'bincount', |