[Numpy-discussion] A bug in boolean indexing?

Alan G Isaac aisaac@american....
Thu Jul 29 06:57:25 CDT 2010


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



More information about the NumPy-Discussion mailing list