Hi,
I have been bitten by a subtlety in numpy scalar divisions. The next
exposes the issue:
>>> -1/20
-1
>>> Numeric.array([-1])[0] / Numeric.array([20])[0]
-1
>>> numarray.array([-1])[0] / numarray.array([20])[0]
-1
>>> numpy.array([-1])[0] / numpy.array([20])[0]
0
After some digging, I've found that Python and C follow different
conventions for doing this negative division: Python do a floor of the
result, while C truncates it. As numpy scalar operations seems to be
implemented in C, it seems that it follows the C convention and
truncates the result.
In fact, I like this behaviour of NumPy scalars (at least, when I'm
aware of it!), but I thought it would be nice to warn other people about
that.
Cheers,
--=20
>0,0< Francesc Altet http://www.carabos.com/
V V C=C3=A1rabos Coop. V. Enjoy Data
"-"
|