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

Travis Oliphant oliphant.travis at ieee.org
Mon Apr 24 22:00:02 EDT 2006


Sasha wrote:
> On 4/24/06, Travis Oliphant <oliphant.travis at ieee.org> wrote:
>   
> I've attached a patch to the ticket:
>
> <http://projects.scipy.org/scipy/numpy/attachment/ticket/76/shape-check.patch>
>   
I don't think the patch will do your definition of  "the right thing" 
(i.e. mirror broadcasting behavior) in all cases.  For example if "a" is 
2x3x4x5 and "b" is 2x1x1x5, then  a[...] = b will not fill the right 
sub-space of "a" with the contents of "b".


The PyArray_CopyInto gets called in a lot of places.  Have you checked 
all of them to be sure that altering the semantics of copying (which are 
currently different than broadcasting) will work correctly?  I agree 
that one can demonstrate a slight in-consistency.  But, I'd rather have 
the inconsistency and tell people that copying and assignment is not a 
broadcasting ufunc, then feign consistency and have it not quite right.


-Travis





More information about the NumPy-Discussion mailing list