[NumPy-Tickets] [NumPy] #2006: Why does recarray assignment fail: "cannot call setfield on an object array"?
NumPy Trac
numpy-tickets@scipy....
Sun Dec 2 16:46:54 CST 2012
#2006: Why does recarray assignment fail: "cannot call setfield on an object
array"?
----------------------------------------------------------+-----------------
Reporter: kevin000 | Owner: somebody
Type: defect | Status: needs_review
Priority: normal | Milestone: 1.7.0
Component: numpy.core | Version: 1.6.2
Keywords: recarray setfield object array runtime error |
----------------------------------------------------------+-----------------
Changes (by ChristianMarquardt):
* cc: christian@… (added)
* status: new => needs_review
* version: devel => 1.6.2
* milestone: Unscheduled => 1.7.0
Comment:
The same problem occurs in 1.6.2 and 1.7.0b2.
The (big) change that introduced this behavior is
https://github.com/numpy/numpy/commit/2635398db3f26529ce2aaea4028a8118844f3c48
and apparently has introduced the error condition on purpose; there's even
a test checking that using the setfield() method on an (ordinary) object
array throws a !RuntimeError.
As modifying object sub-arrays using the dictionary approach works fine,
the easiest solution seems to be to replace the setfield() method in the
__setattr__() method of recarray with ndarray's __setitem__() method; I
just attached a patch against the 1.7.0b2 distribution of numpy which
runns successfully through the same tests as the original distribution
does.
I know way too little about numpy internals to judge if this patch is
consistent with the numpy conventions etc.; but keeping this bug in
recarrays somehow make the whole recarray class superfluous if not fixed
IMHO.
Thanks for considering the patch,
Christian.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/2006#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list