[SciPy-User] problems handling a numpy array

Gabriele Brambilla gb.gabrielebrambilla at gmail.com
Wed Apr 30 11:20:40 EDT 2014


No you are right,
I have to write it in this way:
MYMAPS = np.zeros([npha, nobs, nex, last-first+1], dtype=float)

thanks

Gabriele


2014-04-30 11:13 GMT-04:00 Robert Kern <robert.kern at gmail.com>:

> On Wed, Apr 30, 2014 at 4:10 PM, Gabriele Brambilla
> <gb.gabrielebrambilla at gmail.com> wrote:
> > Hi,
> >
> > I have a 4d numpy array.
> >
> > I want to select an "index" of the fourth dimension to obtain a 3d array.
> >
> > I try to di it in this way:
> >
> > MYMAP = MYMAPS[:, :, :,  1]
> >
> > that is defined in this way:
> > MYMAPS = [np.zeros([npha, nobs, nex, last-first+1], dtype=float)]
> >
> > but I receive an error:
> > TypeError: list indices must be integers, not tuple
> >
> > what am I doing wrong?
>
> You have made MYMAPS a list with an array inside it. Did you mean to
> do this, instead?
>
>   MYMAPS = np.zeros([npha, nobs, nex, last-first+1], dtype=float)
>
> --
> Robert Kern
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20140430/ba9bfe98/attachment.html>


More information about the SciPy-User mailing list