[Numpy-discussion] Faulty behavior of numpy.histogram?

Danny Handoko danny.handoko at asml.com
Wed Aug 12 03:12:09 EDT 2009


Dear all,

We try to use numpy.histogram with combination of matplotlib.  We are using numpy 1.3.0, but a somewhat older matplotlib version of 0.91.2.
Matplotlib's  axes.hist() function calls the numpy.histogram, passing through the 'normed' parameter.  However, this version of matplotlib uses '0' as the default value of 'normed' (I see it fixed in higher version).  What I found strange is that if the 'normed' parameter of numpy.histogram is set with other object than 'True' or 'False', the output becomes None, but no exceptions are raised.  As a result, the matplotlib code that does something like this:

>>> n, bins = numpy.histogram([1,2,3], 10, range = None, normed = 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not iterable
results in the above exception.

Secondly, this matplotlib version also expects both outputs to be of the same length, which is no longer true with the new histogram semantics.  This can be easily reverted using the parameter 'new = False' in numpy.histogram, but this parameter is not available for the caller of axes.hist() function in matplotlib.  Is there any way to tell numpy to use the old semantics?

Upgrading to the newer matplotlib is a rather longer term solution, and we hope to be able to find some workaround/short-term solution

Thank you,


--

Danny Handoko

System Architecture and Generics

Room 7G2.003 -- ph: x2968

email: danny.handoko at asml.com




-- 
The information contained in this communication and any attachments is confidential and may be privileged, and is for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited.  Unless explicitly stated otherwise in the body of this communication or the attachment thereto (if any), the information is provided on an AS-IS basis without any express or implied warranties or liabilities.  To the extent you are relying on this information, you are doing so at your own risk.   If you are not the intended recipient, please notify the sender immediately by replying to this message and destroy all copies of this message and any attachments. ASML is neither liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090812/6df30805/attachment.html>


More information about the NumPy-Discussion mailing list