[Numpy-discussion] untenable matrix behavior in SVN
Anne Archibald
peridot.faceted@gmail....
Tue Apr 29 16:18:23 CDT 2008
On 29/04/2008, Keith Goodman <kwgoodman@gmail.com> wrote:
> On Tue, Apr 29, 2008 at 11:21 AM, Alan G Isaac <aisaac@american.edu> wrote:
> > On Tue, 29 Apr 2008, Keith Goodman apparently wrote:
> > > I often use x[i,:] and x[:,i] where x is a matrix and i is
> > > a scalar. I hope this continues to return a matrix.
> >
> > 1. Could you give an example of the circumstances of this
> > use?
>
>
> In my use i is most commonly an array (i = M.where(y.A)[0] where y is
> a nx1 matrix), sometimes a list, and in ipython when debugging or
> first writing the code, a scalar. It would seem odd to me if x[i,:]
> returned different types of objects based on the type of i:
>
> array index
> idx = M.where(y.A)[0] where y is a nx1 matrix
> x[dx,:] --> matrix
>
> list index
> idx = [0]
> x[idx,:] --> matrix?
>
> scalar index
> idx = 0
> x[idx,:] --> not matrix
It is actually pretty unreasonable to hope that
A[0]
and
A[[1,2,3]]
or
A[[True,False,True]]
should return objects of the same rank.
Anne
More information about the Numpy-discussion
mailing list