[Numpy-discussion] Silent Broadcasting considered harmful

Nathaniel Smith njs at pobox.com
Sun Feb 8 17:47:52 EST 2015


On 8 Feb 2015 13:39, "Simon Wood" <sgwoodjr at gmail.com> wrote:
>
> I find the broadcasting aspect of Numpy a turn off. If I go to add a 1x3
vector to a 3x1 vector, I want the program to warn me or error out. I don't
want it to do something under the covers that has no mathematical basis or
definition. Also, Octave may provide a warning, but Matlab errors
out..."Matrix dimensions must agree". Which they must, at least in my world.

There may be another matlab/numpy idiom clash here that's affecting this:
in MATLAB, vectors are always 1 x n or n x 1, because of the matrix focused
history. In numpy the idiomatic thing to do is to make vectors
one-dimensional, and then this confusion cannot arise. Indeed, the only
cases I'm thinking of where I even create a 3x1 or 1x3 vector in the first
place are when I'm about to do something clever with broadcasting.

-n
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150208/6a636da7/attachment.html>


More information about the NumPy-Discussion mailing list