[SciPy-user] histogram bug ?

Hugo Gamboa hgamboa at gmail.com
Fri Dec 30 14:09:38 EST 2005


I encountered the same error, and It seems that the variable "a" is used to
receive the data and to generate the bins.

I've changed the name of the variable "a" to something else in line 115 of
function_base.py and it solved the problem.

But when looking at the created bins it produced unbalanced bins in the
borders.

Example:
In [17]: histogram(linspace(-1,1,100))
Out[17]:
(array([11, 11, 11, 11, 11, 11, 11, 11, 11,  1]),
 array([-1.        , -0.77777778, -0.55555556, -0.33333333, -0.11111111,
        0.11111111,  0.33333333,  0.55555556,  0.77777778,  1.        ]))


Each bin should have 10 counts instead of 11 leaving the last bin with 1.

Will check the code to see if I can suggest a fix.

Hugo Gamboa







On 12/30/05, Gary <pajer at iname.com> wrote:
>
> WinXP, scipy_core version 0.9.0.1713
>
> tried to call scipy.histogram with the default bins=10. See below.
>
>
> It works ok if I make my own bins.
>
>
>
> ========================================
>
> In [288]: f
> Out[288]:
> array([  46.,   59.,   77.,   87.,   50.,   97.,   84.,   73.,  100.,
>          34.,   86.,   67.,   68.,  100.,   74.,   81.,   94.,   66.,
>          52.,   66.,   69.,   54.,   85.,   97.,   31.,   49.])
>
> In [289]: scipy.histogram(f)
>
> ---------------------------------------------------------------------------
> exceptions.TypeError                                 Traceback (most
> recent call
> last)
>
>
> c:\python24\Lib\site-packages\scipy\base\function_base.py in
> histogram(a, bins,
> range, normed)
>     116
>     117     n = a.sort().searchsorted(bins)
> --> 118     n = concatenate([n, [len(a)]])
>     119     n = n[1:]-n[:-1]
>     120
>
> TypeError: len() of unsized object
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20051230/dbccf601/attachment.html>


More information about the SciPy-User mailing list