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

Sasha ndarray at mac.com
Mon Apr 24 18:26:07 CDT 2006


On 4/24/06, Travis Oliphant <oliphant.travis at ieee.org> wrote:
> Sasha wrote:
> >>>> x[:]=1,1
> >>>> x[:]=1,1,1
> >>>>
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in ?
> > ValueError: number of elements in destination must be integer multiple
> > of number of elements in source
> >
> I think the only reasonable thing to do is to raise an error unless the
> shapes were compatible like Numeric did and eliminate the multiple
> copying feature.

I've attached a patch to the ticket:

<http://projects.scipy.org/scipy/numpy/attachment/ticket/76/shape-check.patch>

I don't see why slice assignment cannot reuse the ufunc code.  It
looks like slice assignment can just be dispatched to a trivial
(pass-through) ufunc.  This aproach may even prove to be faster
because type-aware copying loops can be faster than memmove on popular
platforms.




More information about the Numpy-discussion mailing list