diff options
author | Alex <aprockhill206@gmail.com> | 2020-05-15 10:43:31 -0700 |
---|---|---|
committer | Alex <aprockhill206@gmail.com> | 2020-07-22 11:59:31 -0700 |
commit | f292b95f153b37e6d6141848d2e806275b175836 (patch) | |
tree | a0c430fa7d2e05eb12361b9ed874d0b78963c117 /numpy/lib/function_base.py | |
parent | 5840165bd7db8628d0d5b318544943a28d799068 (diff) | |
download | numpy-f292b95f153b37e6d6141848d2e806275b175836.tar.gz |
fixed simplify
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 3199c6169..e2f5cdd6f 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -4844,11 +4844,16 @@ def digitize(x, bins, right=False, edge=False): raise ValueError("bins must be monotonically increasing or decreasing") if edge: - # move first bin eps if right edge not included else move last bin - idx = 0 if right else -1 - # move bin down if going up and using right or going down and using - # left else move bin up - delta = -mono if right else mono + # ========= ============= ============================ ===== ===== + # `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 = 0 if delta != mono else -1 if np.issubdtype(bins.dtype, _nx.integer): bins[idx] += delta else: |