[Numpy-discussion] curious behavior with indexed assignment

Stéfan van der Walt stefan@sun.ac...
Thu Aug 26 05:16:05 CDT 2010


On 26 August 2010 03:16, Nathaniel Smith <njs@pobox.com> wrote:
> So on IRC #scipy just now, Carlos Scheidegger pointed out some
> behavior that I at least find very surprising:
>
>>>> a = np.zeros(10)
>>>> a[:] = np.arange(3)
> ValueError: shape mismatch: objects cannot be broadcast to a single shape

Another one you'll find interesting:

x.flat = np.arange(3)

Cheers
Stéfan


More information about the NumPy-Discussion mailing list