diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2006-06-30 11:59:07 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2006-06-30 11:59:07 +0000 |
commit | bbabc5c6e3ac6356056ec3f997c81bd430f3214b (patch) | |
tree | 95d26a4a0335c29c76154d6c620ef2c44b46de0a /numpy/lib/function_base.py | |
parent | 339afa63fa51f0dec49adfc5b700f2b30f60407a (diff) | |
download | numpy-bbabc5c6e3ac6356056ec3f997c81bd430f3214b.tar.gz |
Add docstring and tests for digitize.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 39ffa4c8e..05dfa9e23 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -21,11 +21,11 @@ from numpy.core.fromnumeric import ravel, nonzero, choose, sort from numpy.core.numerictypes import typecodes from numpy.lib.shape_base import atleast_1d from numpy.lib.twodim_base import diag -from _compiled_base import digitize, bincount, _insert, add_docstring +from _compiled_base import bincount, _insert, add_docstring +from _compiled_base import digitize as _digitize #end Fernando's utilities - def linspace(start, stop, num=50, endpoint=True, retstep=False): """Return evenly spaced numbers. @@ -378,6 +378,17 @@ def diff(a, n=1, axis=-1): else: return a[slice1]-a[slice2] +def digitize(x,bins): + """For each value in x, return the index of the bin to which it 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. + + Beyond the bounds of the bins 0 or len(bins) is returned as appropriate. + """ + return _digitize(x,bins) + def angle(z, deg=0): """Return the angle of the complex argument z. """ |