[Numpy-discussion] weird indexing

Pearu Peterson pearu at cens.ioc.ee
Fri Jan 4 05:37:39 EST 2008


On Fri, January 4, 2008 2:16 am, Mathew Yeates wrote:
> Hi
> Okay, here's a weird one. In Fortran you can specify the upper/lower
> bounds of an array
> e.g. REAL A(3:7)
>
> What would be the best way to translate this to a Numpy array? I would
> like to do something like
> A=numpy.zeros(shape=(5,))
> and have the expression A[3] actually return A[0].
>
> Or something. Any thoughts?

f2py wraps A(3:7) to numpy array A[0:5] and keeps it that way
as it is most natural for working in Python side.

Pearu




More information about the NumPy-Discussion mailing list