[Numpy-discussion] recarray field access: cannot call setfield on an object array

Christoph Gohle christoph.gohle at mpq.mpg.de
Sun Nov 27 11:47:15 EST 2011

I have a problem with recarray field access using attributes:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
Type "help", "copyright", "credits" or "license" for more information.
>>> from numpy import *
>>> a = recarray(5,formats = ['i4','f8','O'],names = ['a','b','c'])
>>> a.a = 5
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "C:\Python26\lib\site-packages\numpy\core\records.py", line 454, in __set
   return self.setfield(val, *res)
RuntimeError: cannot call setfield on an object array

This is on numpy version 1.6.0 from the pythonxy distribution on windows 7. Access using a['a'] works as expected. What am I doing wrong?



More information about the NumPy-Discussion mailing list