[Numpy-discussion] matrix indexing question
Travis Oliphant
oliphant@ee.byu....
Tue Mar 27 14:11:36 CDT 2007
Alan Isaac wrote:
> On Mon, 26 Mar 2007, Travis Oliphant wrote:
>
>> It actually has been offered. You just don't accept it.
>> Matrices are containers of matrices.
>> If M is an (mxn) matrix then M[0] is a (1xn) matrix.
>> Viewing this 1xn matrix as a 1-d array loses it's row-vectorness.
>> This seems perfectly logical and acceptable to me. I'm waiting for a
>> better explanation as to why this is not acceptable.
>> Arguments that rest on what is and what isn't "Pythonic" are not very
>> persuasive as this is very often in the eye of the beholder.
>>
>
> Again, I only raised a *question* about whether
> there might be a design problem here.
Thanks for listing your points. I can see that this is an issue where
reasonable people will disagree because there are multiple ways of
looking at it.
The idea that matrix selection would return matrices really comes from
wanting to keep matrices more persistent through operations.
M[0] could be seen either as a 1xn matrix or a n-length array. I
agree that both concepts are possible. Seeing it as a 1xn matrix allows
matrices to remain persistent more often.
So, the arguments for the current approach and the arguments against it
to me seem on the same level, so I don't see a reason to change the
current behavior and see a lot of strong reasons not to change the
behavior (we are in a 1.0 release and could not change anything until at
least 1.1 anyway).
With that said:
One of my goals for the next year or two is to create a matrix class in
C and incorporate CVXOPT matrices and it's coupled sparse matrix. We
can re-visit this question in that process. I would like for there to
be a sparse matrix implementation in NumPy (without the solver which
will remain in SciPy).
But, the sparse matrix and the matrix need to have the same behaviors
and should be able to interoperate with each other.
So, if you would like to help with that project all input is welcome.
Best regards,
-Travis
> My goal
> was only to have this explored, and I've tried
> to explain why.
>
> The evidence I offer:
> - it is surprising (at least to some) that iterating
> over a matrix yields matrices
> - I believe it is unexpected (prior to instruction) and that
> there is a natural more expected behavior
> - if that is right, deviation from the expected should have
> a good justification
> - this behavior has tripped up at least a couple people and
> I expect that to happen to many others over time (because
> I believe the behavior is unexpected)
> - when I desire to iterate over a matrix I always want the
> arrays. (Of course there is a way to have them; that's
> not the point). I'm interested to see a use case where
> the rows are desired as matrices
>
> As you indicate, none of this constitutes an "argument".
> And since nobody appears to agree, I should shut up.
> This will be my last post on this subject.
>
> Cheers,
> Alan Isaac
>
>
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
More information about the Numpy-discussion
mailing list