[Numpy-discussion] Priority rules between numpy scalars and 0d arrays
Pierre GM
pgmdevlist at gmail.com
Mon Oct 13 13:35:23 EDT 2008
All,
Sorry to bring back this subject, but I still haven't got any proper answers:
* What are the priority rules between numpy scalars and 0d arrays ?
When multiplying a numpy scalar by a 0d array, shouldn't the __mul__ or
__rmul__ methods of the array be called ?
Should the result be a numpy scalar, or a 0d array (possibly recasted to the
higher dtype) ?
The problem occurs with numpy.ma.masked, defined as a 0d, np.float64
MaskedArray, which has the __mul__ and __rmul__ of a MaskedArray.
np.float(1)*ma.masked gives ma.masked, as it should
np.float(64)* ma.masked gives 0, when ma.masked should have been obtained:
that leads me to think that ma.masked.__rmul__ isn't called. Why ? Are 0d
arrays that special beasts ?
More information about the NumPy-Discussion
mailing list