Consider the following:

>>> import numpy as np
>>> np.__version__
'1.6.1'
>>> arr = np.asarray([[1, 2, 3]])
>>> arr["0"]
Traceback (most recent call last):
  File "<ipython-input-5-28d5d8b86f9b>", line 1, in <module>
    arr["0"]
ValueError: field named 0 not found.

>>> arr["0",]
array([1, 2, 3])
>>> arr["0", 1]
2
>>> arr[0, "1"]
2
>>> arr[1]
Traceback (most recent call last):
  File "<ipython-input-9-62bda37481b6>", line 1, in <module>
    arr[1]
IndexError: index out of bounds

>>> arr[1, 1]
Traceback (most recent call last):
  File "<ipython-input-13-61422633ac63>", line 1, in <module>
    arr[1, 1]
IndexError: index (1) out of range (0<=index<1) in dimension 0

>>> arr["1", "1"]
Traceback (most recent call last):
  File "<ipython-input-14-2e114ec345f6>", line 1, in <module>
    arr["1", "1"]
IndexError: index (1) out of range (0<=index<0) in dimension 0


Is there some kind of logic here, or is this just accumulated cruft?
IMHO, strings should simply never be coerced to int when indexing.

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to