A bug in boolean indexing?

The following does not raise an error: a = np.arange(5) a[a>0] = a although a.shape == (5,) while a[a>0].shape == (4,) I get in on python2.6.5, numpy 1.4.1 on win32, and python 2.6.5, numpy 2.0.0.dev8469 on linux64. Nadav.

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. Nadav. -----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.) fwiw, Alan Isaac _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (2)
-
Alan G Isaac
-
Nadav Horesh