[Numpy-discussion] Recarray attributes writeable
Fernando Perez
fperez.net at gmail.com
Sat Jun 17 11:27:42 EDT 2006
On 6/17/06, Francesc Altet <faltet at carabos.com> wrote:
> However, I think that this has its utility, specially when accessing to
> nested fields (see later). In addition, I'd suggest introducing a
> special accessor called, say, 'fields' in order to access the fields
> themselves and not the attributes. For example, if you want to access
> the 'strides' attribute, you can do it in the usual way:
>
> >>> import numpy
> >>> tr=numpy.recarray(10, formats='i4,f8,f8', names='id,ra,strides')
> >>> tr.strides
> (20,)
>
> but, if you want to access *field* 'strides' you could do it by issuing:
>
> >>> tr.fields.strides
> <repr of field accessor object (shape, type...)>
> >>> tr.fields.strides[:]
> array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
[...]
+1
I meant to write exactly the same thing, but was too lazy to do it :)
Cheers,
f
More information about the NumPy-Discussion
mailing list