[Numpy-discussion] numpy release
Christopher Barker
Chris.Barker@noaa....
Thu Apr 24 20:23:29 CDT 2008
Alan G Isaac wrote:
> On Thu, 24 Apr 2008, Christopher Barker apparently wrote:
>> I suppose a "Vector" can be either a (n,1) or a (1,n)
>> matrix that allows single indexing.
>
> This bothers me.
>
> So, if X is 2 by 2, then X[0] will be a row vector.
> But if X is 1 by 2, then X[0] will be a scalar?
> Ouch!
> Bye bye generic code.
exactly one of the things that really bugged me with MATLAB!
> Or are you still having separate classes and
> not just changing ``__getitem__``? OK, I see
> that is most likely what you meant.
yes, it would still be a vector class, so a 1 by 2 matrix (or array)
would still act like a 2-d object.
The only issue here is if you need a separate "row vector" and "column
vector" class -- I think it's a matter of what whether these vectors are
special versions of 1-d arrays or 2-d matrices. I kind of like them as
special versions of 1-d arrays, as a vector is a 1-d object, but I see
that the implementation is a bit cleaner if you just make them 2-d
matrices with a different scalar indexing.
-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