Hi,

I just wrote a short test for indexing into structured arrays with
strings and found this:

In [4]: a = np.zeros((1,), dtype=[('f1', 'i4')])
In [5]: a['f1']
Out[5]: array([0])
In [6]: a['f2']  # not present -> error
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/Users/mb312/<ipython console> in <module>()

ValueError: field named f2 not found.
In [7]: a[0]['f1'] # OK
Out[7]: 0
In [8]: a[0]['f2']
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)

/Users/mb312/<ipython console> in <module>()

IndexError: invalid index

It seems odd to raise an 'IndexError' without a message about the
field name in the second case, and a ValueError with a good message in
the first.

Do y'all agree?

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

Reply via email to