diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-03-26 00:25:11 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2018-03-26 00:52:37 -0700 |
commit | 52a739e2c1172876fb444a73dafd23247c826d6e (patch) | |
tree | 8ba2f24b986a2232301de22d2aad038f54da9e7d /numpy/lib/histograms.py | |
parent | 89b402a9dab57c45eca0f942bde699ee6961a1f5 (diff) | |
download | numpy-52a739e2c1172876fb444a73dafd23247c826d6e.tar.gz |
MAINT: Only check bin monotonicity if not using linspace
This also switches to doing comparisons rather than subtractions, for consistency with np.histogram.
That change is not strictly necessary here as the arguments are not unsigned integer types (unlike in np.histogram), but it would nice to support integer bins in future.
Diffstat (limited to 'numpy/lib/histograms.py')
-rw-r--r-- | numpy/lib/histograms.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/numpy/lib/histograms.py b/numpy/lib/histograms.py index 50bafec8c..097df2053 100644 --- a/numpy/lib/histograms.py +++ b/numpy/lib/histograms.py @@ -888,13 +888,14 @@ def histogramdd(sample, bins=10, range=None, normed=False, weights=None): edges[i] = np.linspace(smin[i], smax[i], bins[i] + 1, dtype=edge_dt) else: edges[i] = np.asarray(bins[i], edge_dt) + # not just monotonic, due to the use of mindiff below + if np.any(edges[i][:-1] >= edges[i][1:]): + raise ValueError( + '`bins[{}]` must be strictly increasing, when an array' + .format(i)) + nbin[i] = len(edges[i]) + 1 # includes an outlier on each end dedges[i] = np.diff(edges[i]) - # not just monotonic, due to the use of mindiff below - if np.any(np.asarray(dedges[i]) <= 0): - raise ValueError( - '`bins[{}]` must be strictly increasing, when an array' - .format(i)) nbin = np.asarray(nbin) |