[Numpy-discussion] untenable matrix behavior in SVN
Christopher Barker
Chris.Barker@noaa....
Mon Apr 28 14:37:17 CDT 2008
oops, typo!
Christopher Barker wrote:
> Gael Varoquaux wrote:
>> I don't know why people are indexing matrices with A[x][y], but they
>> shouldn't.
>
> I think there has been a misunderstanding here. I don't think anyone is
> suggesting that if a coder wants an element of a matrix, that s/he
> should write that:
>
> element = M[i,j]
I meant -- no one is suggesting:
element = M[i][j]
because, of course, M[i,j] is exactly what you should do do get an element.
Which, by the way, brings up another inconsistency in the current behavior:
>>> M
matrix([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
>>> M[1,1]
5
>>> M[1,:]
matrix([[4, 5, 6]])
so if you pull out a single element, you get a scalar(0-d), but if you
pull out a row, you get a matrix(2-d). It makes me want vectors more...
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
More information about the Numpy-discussion
mailing list