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? thanks Gabriele
On Wed, Apr 30, 2014 at 4:10 PM, Gabriele Brambilla <gb.gabrielebrambilla@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
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@gmail.com>:
On Wed, Apr 30, 2014 at 4:10 PM, Gabriele Brambilla <gb.gabrielebrambilla@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@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
participants (2)
-
Gabriele Brambilla -
Robert Kern