diff options
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 41caa805e..6ea9cc4de 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -4733,12 +4733,12 @@ def append(arr, values, axis=None): return concatenate((arr, values), axis=axis) -def _digitize_dispatcher(x, bins, right=None, edge=None): +def _digitize_dispatcher(x, bins, right=None): return (x, bins) @array_function_dispatch(_digitize_dispatcher) -def digitize(x, bins, right=False, edge=False): +def digitize(x, bins, right=False): """ Return the indices of the bins to which each value in input array belongs. @@ -4767,10 +4767,6 @@ def digitize(x, bins, right=False, edge=False): does not include the right edge. The left bin end is open in this case, i.e., bins[i-1] <= x < bins[i] is the default behavior for monotonically increasing bins. - edge : bool, optional - Whether to include the last right edge if right==False or the first - left edge if right==True so that the whole interval from the least - to the greatest value of bins is covered. Returns ------- @@ -4786,7 +4782,7 @@ def digitize(x, bins, right=False, edge=False): See Also -------- - bincount, histogram, unique, nextafter, searchsorted + bincount, histogram, unique, searchsorted Notes ----- @@ -4843,22 +4839,6 @@ def digitize(x, bins, right=False, edge=False): if mono == 0: raise ValueError("bins must be monotonically increasing or decreasing") - if edge: - # ========= ============= ============================ ===== ===== - # `right` order of bins returned index `i` satisfies delta index - # ========= ============= ============================ ===== ===== - # ``False`` increasing ``bins[i-1] <= x < bins[i]`` 1 -1 - # ``True`` increasing ``bins[i-1] < x <= bins[i]`` -1 0 - # ``False`` decreasing ``bins[i-1] > x >= bins[i]`` 1 0 - # ``True`` decreasing ``bins[i-1] >= x > bins[i]`` -1 -1 - # ========= ============= ============================ ===== ===== - delta = -1 if right else 1 - idx = -1 if delta == mono else 0 - if np.issubdtype(bins.dtype, _nx.integer): - bins[idx] += delta - else: - bins[idx] = np.nextafter(bins[idx], bins[idx] + delta) - # this is backwards because the arguments below are swapped side = 'left' if right else 'right' if mono == -1: |