[Numpy-discussion] Help needed with the priority of 0d-arrays and np.scalars
Tue Sep 30 16:36:59 CDT 2008
On Tuesday 30 September 2008 17:18:13 Travis E. Oliphant wrote:
> Hmm... I'm not 100% sure off the top of my head, but I would say that
> 0d arrays should determine the type coercion if any and the returned
> thing should be a numpy scalar.
I'm afraid I don't understand. According to you, a 0d array should always have
the priority on a numpy scalar, right ? That doesn't seem to be the case:
ma.masked is a 0d ndarray with a np.float64 dtype and a __array__priority__ of
15. It implements special __mul__ and __rmul__ methods.
The multiplication `ma.masked * np.float64(1)` calls `ma.masked.__mul__`, as
The multiplication `np.float64(1)*ma.masked` doesn't call `ma.masked.__mul__`
However, `np.float32(1)*ma.masked` does.
How could I force `np.float64(1)*ma.masked` to call the proper method ?
More information about the Numpy-discussion