We recently deprecated matplotlib.mlab.hist, and I am now hitting a
bug in numpy's historgram, which appears to be caused by the use of
"any" that does not exist in the namespace.  Small patch attached.
The example below exposes the bug:

Python 2.4.2 (#1, Feb 23 2006, 12:48:31)
Type "copyright", "credits" or "license" for more information.

IPython 0.8.3.svn.r2876 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: import numpy as np

In [2]: np.__file__
Out[2]: '/home/titan/johnh/dev/lib/python2.4/site-packages/numpy/__init__.pyc'

In [3]: np.__version__
Out[3]: '1.0.5.dev4814'

In [4]: x = np.random.randn(100)

In [5]: bins = np.linspace(x.min(), x.max(), 40)

In [6]: y = np.histogram(x, bins=bins)
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in ?
  File 
"/home/titan/johnh/dev/lib/python2.4/site-packages/numpy/lib/function_base.py",
line 155, in histogram
    if(any(bins[1:]-bins[:-1] < 0)):
NameError: global name 'any' is not defined
Index: numpy/lib/function_base.py
===================================================================
--- numpy/lib/function_base.py	(revision 4814)
+++ numpy/lib/function_base.py	(working copy)
@@ -152,7 +152,7 @@
         bins = linspace(mn, mx, bins, endpoint=False)
     else:
         bins = asarray(bins)
-        if(any(bins[1:]-bins[:-1] < 0)):
+        if(bins[1:]-bins[:-1] < 0).any():
             raise AttributeError, 'bins must increase monotonically.'
 
     # best block size probably depends on processor cache size
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to