[SciPy-User] Order of numpy orperations is not equal to logic (and also octave)?
Charles R Harris
charlesr.harris@gmail....
Sun Oct 31 15:40:26 CDT 2010
On Sun, Oct 31, 2010 at 2:30 PM, Oz Nahum Tiram <nahumoz@gmail.com> wrote:
> Continuing this subject, I have a feeling that numpy behaves in very
> un-intuitive way for me.
> Here is an example that someone gave me in Stackoverflow.com:
>
> >>> import numpy as np
> >>> a=np.array([1,0])
> >>> b=np.array([-1,1])
>
> >>> np.sum(a)/np.sum(b)
> 0
> >>> np.sum(a)/b
> array([-1, 1])
> >>> np.sum(a)/0
> 0
>
>
It's a version problem:
In [1]: a=np.array([1,0])
In [2]: b=np.array([-1,1])
In [3]: np.sum(a)/np.sum(b)
Warning: divide by zero encountered in long_scalars
Out[3]: 0
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20101031/b056c48f/attachment-0001.html
More information about the SciPy-User
mailing list