[Numpy-discussion] Bug in numpy.histogram?

David Huard david.huard@gmail....
Mon Jun 9 15:50:12 CDT 2008


2008/6/9 Tommy Grav <tgrav@mac.com>:

> I understand this and agree, but it still means that the API for
> histogram is
> broken since normed can only be used with the new=True parameter. I
> though
> the whole point of the future warning was to avoid this. It is not a
> big deal,
> just means that one is forced to use the new API somewhat quicker :)
>

Tommy,

you should be able to use normed=True as long as bins edges are not
specified explicitly.
That is, by setting bins=number_of_bins and range=[bin_min, bin_max], normed
should not raise any warning.

The case bins=edges_array and normed=True was simply too ugly too fix using
the old calling semantic due to this right edge at infinity problem. Also,
since there was a bug in histogram for this combination, we thought it just
as well to force the switch to the new behavior.

Sorry for the inconvenience,

David





>
> Cheers
>    Tommy
>
>
>
> On Jun 9, 2008, at 11:17 AM, Pauli Virtanen wrote:
>
> > ma, 2008-06-09 kello 11:11 -0400, Tommy Grav kirjoitti:
> >> With the most recent change in numpy 1.1 it seems that
> >> numpy.histogram
> >> was broken when wanting a normalized histogram. I thought the idea
> >> was
> >> to leave the functionality of histogram as it was in 1.1 and then
> >> break the api in 1.2?
> > [clip]
> >> data, bins = numpy.histogram(a,b,normed=True)
> >> Traceback (most recent call last):
> >>   File "<console>", line 0, in <module>
> >>   File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
> >> python2.5/site-packages/numpy/lib/function_base.py", line 189, in
> >> histogram
> >>     raise ValueError, 'Use new=True to pass bin edges explicitly.'
> >> ValueError: Use new=True to pass bin edges explicitly.
> >
> > I think the point in this specific change was that numpy.histogram
> > previously returned invalid results when normed=True and explicit bins
> > were given; the previous code always normalized the results assuming
> > the
> > bins were of equal size.
> >
> > Moreover, I think it was not obvious what "normalized" results should
> > mean when one of the bins is of infinite size.
> >
> >       Pauli
> >
> >
> > _______________________________________________
> > Numpy-discussion mailing list
> > Numpy-discussion@scipy.org
> > http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080609/d08c0d00/attachment-0001.html 


More information about the Numpy-discussion mailing list