Not sure whether this is a bug or a propossed enhancement (I as not expecting the cube to behave differently to the numpy array but maybe that is a wrong assumption to have):
import iris.tests.stock as stock
cube = stock.lat_lon_cube()
slices = [slice(None), slice(None)]
print 'THIS WORKS: ', cube[slices[0], slices[1]].shape
print 'THIS WORKS TOO: ', cube.data[slices].shape
print "BUT THIS DOESN'T: ", cube[slices].shape
THIS WORKS: (3, 4)
THIS WORKS TOO: (3, 4)
BUT THIS DOESN'T:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-92-3cbd726cd4b6> in <module>()
4 print 'THIS WORKS: ', cube[slices[0], slices[1]].shape
5 print 'THIS WORKS TOO: ', cube.data[slices].shape
----> 6 print "BUT THIS DOESN'T: ", cube[slices].shape
/home/carwyn/git/iris/lib/iris/cube.pyc in __getitem__(self, keys)
1940
1941 if first_slice is not None:
-> 1942 data = self._my_data[first_slice]
1943 else:
1944 data = copy.deepcopy(self._my_data)
TypeError: long() argument must be a string or a number, not 'slice'
Basically I was expecting cube[slices] to work as it does with a numpy array
Update: works if slices is a tuple rather than a list. Now I think this a bug.
At numpy 1.19
cube.data[slices].shape
gives
FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
So it seems numpy is being brought into line with iris 馃榾
Happy to close in that case, thanks .
Most helpful comment
At numpy 1.19
gives
FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.So it seems
numpyis being brought into line withiris馃榾