# [SciPy-User] Order of numpy orperations is not equal to logic (and also octave)?

Oz Nahum Tiram nahumoz@gmail....
Sun Oct 31 15:30:14 CDT 2010

```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

Octave warns when dividing by zero:
octave:1> a=[1,0]
a =

1   0

octave:2> b=[-1,1]
b =

-1   1

octave:3> sum(a)/sum(b)
warning: division by zero
ans = Inf
octave:4> sum(a)./sum(b)
warning: division by zero
ans = Inf
octave:5> sum(a)./b
ans =

-1   1

I think this is very important that these differences are broad-casted to
new comers from matlab/octave to python and numpy.
I work interchangeably with both, and this is quite tricky...

--
Oz Nahum
Zentrum für Angewandte Geologie
Universität Tübingen

---

Imagine there's no countries
it isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20101031/803cf5c0/attachment.html
```