summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authordhuard <dhuard@localhost>2008-04-25 21:04:16 +0000
committerdhuard <dhuard@localhost>2008-04-25 21:04:16 +0000
commit1c89c150f154da809e82c038127d7db8d597225b (patch)
tree8c46d9c235f016b9de2be872ff3da2787bf9feff /numpy/lib/function_base.py
parentb64dbce29b86a1ab206029ae397091e067645ad9 (diff)
downloadnumpy-1c89c150f154da809e82c038127d7db8d597225b.tar.gz
histogram: an error is raised for varying bin widths only if normed=True.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 0470930f5..d84038413 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -173,15 +173,25 @@ def histogram(a, bins=10, range=None, normed=False, weights=None, new=False):
if range is None:
range = (a.min(), a.max())
else:
- warnings.warn("""Outliers handling will change in version 1.2.
- Please read the docstring for details.""", FutureWarning)
+ warnings.warn("""
+ Outliers handling will change in version 1.2.
+ Please read the docstring for details.""", FutureWarning)
mn, mx = [mi+0.0 for mi in range]
if mn == mx:
mn -= 0.5
mx += 0.5
bins = linspace(mn, mx, bins, endpoint=False)
else:
- raise ValueError, 'Use new=True to pass bin edges explicitly.'
+ if normed:
+ raise ValueError, 'Use new=True to pass bin edges explicitly.'
+ warnings.warn("""
+ The semantic for bins will change in version 1.2.
+ The bins will become the bin edges, instead of the left bin edges.
+ """, FutureWarning)
+ bins = asarray(bins)
+ if (np.diff(bins) < 0).any():
+ raise AttributeError, 'bins must increase monotonically.'
+
if weights is not None:
raise ValueError, 'weights are only available with new=True.'