Ok that are indeed some good reasons to keep the status quo, especially since performance is crucial for numpy.
 
It's a dillemma: Using the matrix class for linear algebra would be the correct way for such thing,
but the matrix API is not that powerful and beautiful as the one of arrays.
On the other hand arrays are beautiful, but not exactly intended to use for linear algebra.
 
So maybe the better way would be not to add warnings to braodcasting operations, but to overhaul the matrix class
to make it more attractive for numerical linear algebra(?)
 
Cheers,
Stefan
Gesendet: Sonntag, 08. Februar 2015 um 23:52 Uhr
Von: "Nathaniel Smith" <n...@pobox.com>
An: "Discussion of Numerical Python" <numpy-discussion@scipy.org>
Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful

On 8 Feb 2015 13:04, "Stefan Reiterer" <dom...@gmx.net> wrote:
>
> So I suggest that the best would be to throw warnings when arrays get Broadcasted like
> Octave do. Python warnings can be catched and handled, that would be a great benefit.
>  
> Another idea would to provide warning levels for braodcasting, e.g
> 0 = Never, 1=Warn once, 2=Warn always, 3 = Forbid aka throw exception,
> with 0 as default.
> This would avoid breaking other code, and give the user some control over braodcasting.

Unfortunately adding warnings is a non-starter for technical reasons, even before we get into the more subjective debate about ideal API design: issuing a warning is extremely slow (relative to typical array operations), EVEN IF the warning is disabled. (By the time you can figure out it's disabled, it's too late.) So this would cause massive slowdowns in existing code.

Note also that in numpy, even simple expressions like '2 * arr' rely on broadcasting. Do you really want warnings for all these cases?

-n

_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to