[Numpy-discussion] sum of two arrays with different shape?

zhang yunfeng zhangyunfeng at gmail.com
Mon Dec 18 20:45:04 EST 2006


2006/12/18, Robert Kern <robert.kern at gmail.com>:
>
> zhang yunfeng wrote:
> > Hi, I'm newbie to Numpy.
> >
> > When reading tutorials at
> > http://www.scipy.org/Tentative_NumPy_Tutorial
> > <http://www.scipy.org/Tentative_NumPy_Tutorial>, I found a snippet about
> > addition of two arrays with different shape, Does it make sense? If
> > array shapes are not same, why it doesn't throw out an error?
>
> When two arrays of different shapes are operated against each other, numpy
> tries
> to "broadcast" them to a compatible shape according to certain rules. This
> is a
> fairly powerful concept, and it provides quite a lot of convenience. The
> following wiki page has an explanation of the broadcasting rules:
>
>   http://www.scipy.org/EricsBroadcastingDoc
>
>
Yes, It seems  powerful. But If one happened  to add two incompatible array
by mistake,  Does the result make sense? May be the broadcast feature should
be limited in a certain range not to mess normal operation.




-- 
http://my.opera.com/zhangyunfeng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20061219/029ed43e/attachment.html>


More information about the NumPy-Discussion mailing list