summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorAlex <aprockhill206@gmail.com>2020-05-15 00:00:48 -0700
committerAlex <aprockhill206@gmail.com>2020-07-22 11:59:30 -0700
commit5db1c6a48c9bf626ad171caab6085eec5b7408ea (patch)
tree1b809b739cc59e316870d5f8f061504e59598002 /numpy/lib/function_base.py
parent8066b45451eff24228bb5af96aad2fe0bd548383 (diff)
downloadnumpy-5db1c6a48c9bf626ad171caab6085eec5b7408ea.tar.gz
changed from large number error to different solution
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index c7f3dc033..c266078cf 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -4845,15 +4845,17 @@ def digitize(x, bins, right=False, edge=False):
if edge:
# if cannot make round trip, cannot use eps
- if np.issubdtype(bins.dtype, _nx.int64):
- if (bins != bins.astype(_nx.float64).astype(_nx.int64)).any():
- raise ValueError("bins have too large values to use"
- "'edges=True'")
- bins = bins.astype(_nx.float64)
- if right:
- bins[0] -= np.finfo(_nx.float64).eps * 2 * mono
+ if np.issubdtype(bins.dtype, _nx.integer):
+ if right:
+ bins[0] -= 1
+ else:
+ bins[-1] += 1
else:
- bins[-1] += np.finfo(_nx.float64).eps * 2 * mono
+ bins = bins.astype(_nx.float64)
+ if right:
+ bins[0] -= np.finfo(_nx.float64).eps * 2 * mono
+ else:
+ bins[-1] += np.finfo(_nx.float64).eps * 2 * mono
# this is backwards because the arguments below are swapped
side = 'left' if right else 'right'