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.
Travis, 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 it should. The multiplication `np.float64(1)*ma.masked` doesn't call `ma.masked.__mul__` nor `ma.masked.__rmul__`. However, `np.float32(1)*ma.masked` does. How could I force `np.float64(1)*ma.masked` to call the proper method ?