Michael McNeil Forbes wrote:
> Could someone please explain the semantics of the following.
>
>
>>>> from numpy import *
>>>> a1 = array([1,2,3])
>>>> a2 = array([[1,2,3]])
>>>> a1[where(a1==3)],a2[where(a2==3)]
>>>>
> (array([3]), 3)
>
> Why are 1-dimensional fundamentally different than N-dimensional arrays
> in this regard? When there is a single match, N-d arrays always return
> a scalar whereas 1-d arrays return an array.
>
> Is this a bug?
>
Yes, it's a bug. The optimization for a[0,2] was being called in this
case because the arrays with 1 element were being interpreted as
integers. I beefed-up the conversion check and fixed this in SVN.
Thanks for the check.
Now both have the same shape.
-Travis
|