summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorKirit Thadaka <kirit.thadaka@gmail.com>2018-02-21 07:30:31 +0530
committerEric Wieser <wieser.eric@gmail.com>2018-02-20 18:00:31 -0800
commit173a9e3eb37826e2524f5dd66aab24fcf203068b (patch)
tree4401c59c49f53b7d3ecb6618721e83b1c2287f69 /numpy
parent32bc5769bbfa0ec00b0c7fb6c0259fddebcbdc4b (diff)
downloadpython-numpy-173a9e3eb37826e2524f5dd66aab24fcf203068b.tar.gz
python-numpy-173a9e3eb37826e2524f5dd66aab24fcf203068b.tar.bz2
python-numpy-173a9e3eb37826e2524f5dd66aab24fcf203068b.zip
MAINT: Improve range error messages in np.histogram (#10603)
Diffstat (limited to 'numpy')
-rw-r--r--numpy/lib/histograms.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/numpy/lib/histograms.py b/numpy/lib/histograms.py
index c5679ace8..ccc6c0616 100644
--- a/numpy/lib/histograms.py
+++ b/numpy/lib/histograms.py
@@ -219,18 +219,20 @@ def _get_outer_edges(a, range):
"""
if range is not None:
first_edge, last_edge = range
+ if first_edge > last_edge:
+ raise ValueError(
+ 'max must be larger than min in range parameter.')
+ if not (np.isfinite(first_edge) and np.isfinite(last_edge)):
+ raise ValueError(
+ "supplied range of [{}, {}] is not finite".format(first_edge, last_edge))
elif a.size == 0:
# handle empty arrays. Can't determine range, so use 0-1.
first_edge, last_edge = 0, 1
else:
first_edge, last_edge = a.min(), a.max()
-
- if first_edge > last_edge:
- raise ValueError(
- 'max must be larger than min in range parameter.')
- if not (np.isfinite(first_edge) and np.isfinite(last_edge)):
- raise ValueError(
- 'range parameter must be finite.')
+ if not (np.isfinite(first_edge) and np.isfinite(last_edge)):
+ raise ValueError(
+ "autodetected range of [{}, {}] is not finite".format(first_edge, last_edge))
# expand empty range to avoid divide by zero
if first_edge == last_edge: