[Numpy-discussion] A bug in boolean indexing?

Nadav Horesh nadavh@visionsense....
Thu Jul 29 12:45:33 CDT 2010

I was not aware that

a[b] = c

where b is an integer or boolean indexing array, is legal even if

a[b].shape != c.shape.


-----Original Message-----
From: numpy-discussion-bounces@scipy.org on behalf of Alan G Isaac
Sent: Thu 29-Jul-10 14:57
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] A bug in boolean indexing?
On 7/29/2010 4:04 AM, Nadav Horesh wrote:
> a = np.arange(5)
> a[a>0] = a

This has nothing to do with reusing ``a``::

         >>> b = np.arange(50)
         >>> a[a>0] = b
         >>> a
         array([0, 0, 1, 2, 3])

Note however that reusing ``a`` is "unsafe".
(You will get all zeros.)

Alan Isaac

NumPy-Discussion mailing list

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 2942 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100729/acb6cc9b/attachment.bin 

More information about the NumPy-Discussion mailing list