[Numpy-discussion] untenable matrix behavior in SVN
Christopher Barker
Chris.Barker at noaa.gov
Tue Apr 29 17:49:22 EDT 2008
Keith Goodman wrote:
> It would seem odd to me if x[i,:]
> returned different types of objects based on the type of i:
I think this is where matrices should act like arrays:
>>> a
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
>>> a[:,[1]]
array([[1],
[4],
[7]])
>>> a[:,1]
array([1, 4, 7])
in this case, it's not really different types, but totally different
concepts -- indexing with a sequence is different than a scalar, just
like indexing with a slice is different than a scalar.
There are many, many places in python code where we have to make
distinctions between a single object and a sequence of objects that
happens to be of length one.
-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 at noaa.gov
More information about the NumPy-Discussion
mailing list