From: Travis O. <oli...@ie...> - 2006-10-28 18:27:06
|
Michael McNeil Forbes wrote: > Is the following the desired behaviour for setting recarray attributes? > This seems to clash with the semantics for arrays. > > >>> from numpy import * > >>> a = array([1,2,3]) > >>> b = a.view([('x',int),('y',int),('z',int)]) > >>> r = b.view(recarray) > >>> b['x'] = 0 > >>> r.y = 0 > >>> a > array([0, 2, 3]) > >>> r.x > array([0]) > >>> r.y > 0 > > Setting r.y creates a local variable in r.__dict__ which is then > accessed rather than the array element referred to by fielddict. > Hmm.... I know that the code was changed at some point a few months ago specifically to this behavior because of some concerns Perry, Chris (people at STScI) had. Originally, field names came first, but we changed it so they could set known attributes of a record array even if they were also field names. This may be an unintentional side-effect. So, let's not just change things again and create problems for them. -Travis |