diff options
author | Jarrod Millman <millman@berkeley.edu> | 2007-10-19 04:33:58 +0000 |
---|---|---|
committer | Jarrod Millman <millman@berkeley.edu> | 2007-10-19 04:33:58 +0000 |
commit | 21b4beeb2aa5692333c4f822ee0471ff3eb63f27 (patch) | |
tree | 55f80b305b4aab19bc01d71c3f19f80dac44c913 /numpy/lib/function_base.py | |
parent | e41b3a4fe166cead069a0c22c818032c22383154 (diff) | |
download | numpy-21b4beeb2aa5692333c4f822ee0471ff3eb63f27.tar.gz |
raise error if histogram is called with a decending range to bin into (see #586)
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 2c7b78e5c..0ca570190 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -108,6 +108,12 @@ def histogram(a, bins=10, range=None, normed=False): """ a = asarray(a).ravel() + + if (range is not None): + mn, mx = range + if (mn > mx): + raise AttributeError, 'max must be larger than min in range parameter.' + if not iterable(bins): if range is None: range = (a.min(), a.max()) @@ -116,6 +122,9 @@ def histogram(a, bins=10, range=None, normed=False): mn -= 0.5 mx += 0.5 bins = linspace(mn, mx, bins, endpoint=False) + else: + if(any(bins[1:]-bins[:-1] < 0)): + raise AttributeError, 'bins must increase monotonically.' # best block size probably depends on processor cache size block = 65536 |