[Numpy-discussion] Bug or feature ?

Todd Miller jmiller at stsci.edu
Mon Jan 24 05:06:06 CST 2005


On Mon, 2005-01-24 at 13:47 +0100, Jean-Luc Menut wrote:

> array([[1, 2],
>         [3, 4]])
> 
>  >>> numarray.sum(a)
> array([4, 6])
> 
> It seems to be impossible to sum all the elements with sum(array).
> 
> With the second,
> 
>  >>> a.sum()
> 10L
> 
> In this case, it's ok but :
> 
>  >>> b
> array(1)
> 
>  >>> b.sum()
> 0L

This is clearly a bug.  In general,  rank-0 and zero-length array
handling is buggy in numarray because my awareness of these issues came
after the fact and these issues were not priorities in Perry's initial
design,  which was after all to process huge astronomical images memory
mapped and across platforms.  We've considered ripping out rank-0
altogether several times.

> I know that it's stupid to sum only one element but it's force me to 
> plan that case in my program (and I don't want to check for each case) 
> if I don't want an error.
> 
> 
> 2) When I want to replace one element in an array :
> 
>  >>> a[0,0]=1.1
>  >>> a
> array([[1, 2],
>         [3, 4]])
> 
> I know that I created the array as an array of integer, but at least I 
> can expect an error message.

numarray and Numeric, consciously,  don't work that way.  So, no,  you
can't expect that.

> Anyboby knows if these behaviour are bugs or not ? 

rank-0 yes,  silent truncation no.


Regards,
Todd





More information about the Numpy-discussion mailing list