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

Sasha ndarray at mac.com
Tue Apr 25 06:59:07 EDT 2006


On 4/25/06, Travis Oliphant <oliphant.travis at ieee.org> wrote:
> 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".
>
You are right, but it is not the fault of my code.  My code checks
shapes correctly, but the code that follows does not implement
broadcasting.  I did not realize that.  This also explains why we
disagreed on whether slice assignment is the same as broadcasting
before.

>
> 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.
>

That's why I would rather use an identity ufunc for slice assignment
instead of PyArray_CopyInto.




More information about the NumPy-Discussion mailing list