[Numpy-discussion] Broadcasting rules (Ticket 76).

Travis Oliphant oliphant.travis at ieee.org
Mon Apr 24 10:43:05 CDT 2006


Sasha wrote:
> I was looking at ticket 76:
>
> http://projects.scipy.org/scipy/numpy/ticket/76
>
> At first, I concluded that the ticket was valid and that
>
>   
>>>> a = zeros([5,2])
>>>> a[:] = arange(5)
>>>>         
>
> should raise an error as it did in Numeric.  However, once I started
> looking at the code, I've realized that numpy supports more flexible
> broadcasting rules than Numeric.
>   
This really isn't in the category of "broadcasting" as I see it.  My 
understanding is that broadcasting refers to operations involving more 
than one array on the input side.   It's really just a "universal 
function" concept. 

A copying operation is not handled using the same rules.   In this case, 
for example, Numeric used to raise an error but in NumPy the array will 
be copied as many times as possible into the array.  I don't believe 
ticket #76 is actually an error.

This behavior could be changed if somebody wants to write the code to 
change it but only until version 1.0.   It would be very difficult to 
change the other broadcasting behavior which was inherited from Numeric, 
however.  The only possibility I see is adding new useful functionality 
where Numeric used to raise an error.


-Travis


  




More information about the Numpy-discussion mailing list