[Numpy-discussion] numpy oddity
Johann Cohen-Tanugi
johann.cohentanugi@gmail....
Tue Aug 30 09:33:05 CDT 2011
I have numpy version 1.6.1 and I see the following behavior :
In [380]: X
Out[380]: 1.0476157527896641
In [381]: X.__class__
Out[381]: numpy.float64
In [382]: (2,3)*X
Out[382]: (2, 3)
In [383]: (2,3)/X
Out[383]: array([ 1.90909691, 2.86364537])
In [384]: X=float(X)
In [385]: (2,3)/X
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/cohen/<ipython-input-385-cafbe080bfd5> in <module>()
----> 1 (2,3)/X
TypeError: unsupported operand type(s) for /: 'tuple' and 'float'
So it appears that X being a numpy float allows numpy to play some trick
on the tuple so that division becomes possible, which regular built-in
float does not allow arithmetics with tuples.
But why is multiplication with "*" not following the same prescription?
best,
Johann
More information about the NumPy-Discussion
mailing list