[Numpy-discussion] structured array indexing oddity

2011-03-15 Thread Matthew Brett
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 ---

Re: [Numpy-discussion] structured array indexing oddity

2011-03-15 Thread Anthony Scopatz
Hi Matt, Actually, based on what is happening under the covers I think this behavior makes sense. a['f2'] would in theory grab the whole column, and so 'f2' not existing is a field error. a[0] on the other hand grabs the first row from the full structured array and treats this as (key, value)