Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when did numpy stop accepting floats as index

Tags:

python

numpy

When did numpy stop accepting floats as index. I get an error when using a float as an index, even when I use

x = np.arange(10)
i = 10 / 2
print(x[i])

I know this was deprecated, but cannot find back what version started to throw an error. I have many students submitting solutions to programming exercises that work for them and not for me. So their version is too old, but I want to know what version they need to upgrade to (I know the latest). When did numpy implement this change?

like image 238
Mark Bakker Avatar asked Mar 09 '23 00:03

Mark Bakker


1 Answers

It's under version 1.12.0's release notes:

DeprecationWarning to error

  • Indexing with floats raises IndexError, e.g., a[0, 0.0].
  • Indexing with non-integer array_like raises IndexError, e.g., a['1', '2']
  • Indexing with multiple ellipsis raises IndexError, e.g., a[..., ...].
  • Non-integers used as index values raise TypeError, e.g., in reshape, take, and specifying reduce axis.
like image 156
ayhan Avatar answered Mar 20 '23 12:03

ayhan