[Numpy-discussion] Bug or feature ?
Jean-Luc Menut
jeanluc.menut at free.fr
Mon Jan 24 04:49:07 CST 2005
Hello,
I'm using numarray, I'm wondering about the behaviour of some functions
which seem odd to me:
1) When I want to sum all the elements of an array, I can do sum(array)
or array.sum() :
With the first method
>>> a
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
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.
Anyboby knows if these behaviour are bugs or not ? And if not, I will be
glad the have somme explication about the choice of this behaviour.
Thanks for your help,
Jean-Luc
More information about the Numpy-discussion
mailing list