[Numpy-discussion] numpy oddity

Johann Cohen-Tanugi johann.cohentanugi@gmail....
Tue Aug 30 14:10:10 CDT 2011

ok thanks a lot. Safe code is often better than over-smart code, so I 
would line up with Charles here. There is too much potential for 
ambiguity in expected behavior.

On 08/30/2011 09:06 PM, Robert Kern wrote:
> On Tue, Aug 30, 2011 at 13:58, Johann Cohen-Tanugi
> <johann.cohentanugi@gmail.com>  wrote:
>> I am not sure I follow : is the problem the coerce-sequences-to-ndarrays
>> behavior, or is it the fact that it applies to division and not
>> multiplication?
>> I thought the second situation is the more problematic.
>> Anyway, you seem to take it as a bug, should I file a ticket somewhere?
> * is the odd one out. /+- all behave the same: they coerce the
> sequence to an ndarray and broadcast the operation. Whether this is
> desirable is debatable, but there is at least a logic to it. Charles
> would rather have it raise an exception.
> (sequence * np.integer) is an interesting case. It should probably
> have the "repeat" semantics. However, this makes it an exception to
> the coerce-to-ndarray-and-broadcast rule with the other operations.
> This gives weight to Charles' preference to make the other operations
> raise an exception.
> What is an unambiguous bug is the behavior of * with a *float* scalar.
> It should never have the "repeat" semantics, no matter what.

More information about the NumPy-Discussion mailing list