![](https://secure.gravatar.com/avatar/6401b8425eed08fcbaffffeeaceac894.jpg?s=120&d=mm&r=g)
Stef Mientki wrote:
thank you all for the explanations.
I'm a practical engineer, who almost never divide by zero. But the question came from my son, familiar with python and a little with scipy. After his first lesson in MatLab, he said: Oh what a beautiful environment is MatLab, it's even capable to divide by zero without errors. So for the moment probably MatLab is better suited for educational purposes.
NO!!!
I'll ask him again to compare scipy and Matlab, after a few weeks ;-)
The fundamental difference here is that Matlab operates using double precision numbers for *everything* by default. I personally consider that a design flaw. Numpy is being smart and letting you use integers if that's what you give it. So this isn't some limitation of numpy, it's just a slight difference of "opinion" between the packages. Numpy is capable of the same behavior with just one of two minor tweaks to the example:
a = np.array([2., 3.]) #Note the decimal points, this makes floats a/0 array([ Inf, Inf])
-or-
a = np.array([2, 3], dtype=np.float32) #Explicitly ask for floats a/0 array([ Inf, Inf], dtype=float32)
Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma