0

I have a piece of code that uses a sophisticated way of calculating slices for an array that used to work, but does not any more as of python 3.8.15.

Can anyone tell me whats wrong with

>>> a=np.zeros((100,100))
>>> b=[slice(5,95),slice(5,95)]
>>> a[b]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

and moreover how to do it correctly?

I'm pretty sure it worked up to python about 3.5 ...

mfeldt
  • 61
  • 1
  • 3

0 Answers0