|
From: Chris B. <Chr...@no...> - 2005-01-31 19:56:40
|
Python is not MATLAB!
Humufr wrote:
> I agree with you but in the load function documentation I can read this:
> and not a file like:
>
> 1 1 1 1 1
> 2 2 2 2 2
>
> it's why I suggest to add the transpose in the load function.
However, Matlab does exactly this, for the same reason. I always thought
that was stupid, but a goal of pylab is to be matlab compatible, so it
should probably not be transposed automatically.
> For the comments for the beggining of an array indexing I know it :) but
> I hate it (it's just a tast :) )
You may come to love it. I know I do. While indexing from 1 seems most
natural at first, it results in ugly arithmetic when slicing. I came
from Matlab, and python's indexing seemed ugly at first, but then I
found that so many thing work much more naturally:
len(a[i:j]) = j-i
len(s[-3:]) = 3
l[i:j] + l[j:k] = l[i:k]
You'd be adding and subtracting a lot of ones if python had one-based
indexing.
Also, if you have a grid, spaced out by DeltaX:
The X -coord of a[i] is:
X0 + i*DeltaX
With one based indexing, it would be:
X0 + (i-1) * DeltaX
But most of all, Python indexes from 0, whether you like it or not, so
it's probably best to stick with that in Python functions.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
|