[Numpy-discussion] numpy oddity

Robert Kern robert.kern@gmail....
Tue Aug 30 14:06:34 CDT 2011

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.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco

More information about the NumPy-Discussion mailing list