[Numpy-discussion] Silent Broadcasting considered harmful

Chris Barker chris.barker at noaa.gov
Mon Feb 9 12:22:35 EST 2015


On Sun, Feb 8, 2015 at 2:17 PM, Stefan Reiterer <domors at gmx.net> wrote:


> Till now the only way out of the misery
> is to make proper unit tests,
>


That's the only way out of the misery of software bugs in general --
nothing special here ;-)

Python is a dynamically typed language -- EVERYTHING could do something
unexpected if you pass in different type, or shape of array or whatever
than you expect. If you want type safety -- use something else ;-)

I'm sorry out had a hard time with a particular bug -- but for me, I find
broadcasting errors to usually be about as shallow as type errors -- which
is to say usually found early and easily.

Providing optional warnings just would be an elegant way out of this.
>

Broadcasting is widely used in numpy code -- a huge pile of warnings would
be really painful!

Do you realize that:

arr = np.ones((5,))

ar2 = arr * 5

is broadcasting, too?

-CHB



-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150209/2bc6d038/attachment.html>


More information about the NumPy-Discussion mailing list