[Numpy-discussion] masked record arrays
Sat Nov 7 16:31:37 CST 2009
On Nov 7, 2009, at 2:26 PM, Thomas Robitaille wrote:
> Thanks for the advice! I'm somewhat confused by the difference between
> structured and record arrays. My understanding is that record arrays
> you to access fields by attribute (e.g. r.field_name), but I imagine
> there are much more fundamental differences for the two to be treated
> separately in numpy.
Actually, no. recarray is just ndarray w/ a special __getattribute__/
__setattr__ . They bring the convenience of exposing fields as
properties, but they come to the cost of overloading __getattribute__
> I find the numpy documentation somewhat confusing in
> that respect - if you have a look at this page
> I think the 'aka record arrays' is especially confusing as this would
> suggest the two are the same.
Not the most fortunate formulation, true...
> So is there good information anywhere about
> what exactly are the differences between the two? This page is also
> as to me "Construct an ndarray that allows field access using
> suggests that all a recarray is is an ndarray/structured array with
> overloaded __getattr__/__setattr__ methods. Is that all recarrays are?
> so, why was a completely separate package developed for masked
> record arrays
> - can one not just use masked structured arrays and overload
Mostly historical reasons. Initially, there was only limited support
for structured masked arrays and masked records filled the gap (albeit
experimentally). With the 1.3 release, MaskedArray fully supports
structured type, giving the possibility to mask individual fields and
masked records became less useful. Still, it's cleaner to have a
specific module where to store functions like fromrecords, fromarrays
and so forth. Note that the doc of numpy.ma.mrecords is a tad
outdated, any help to this regard would be welcome.
More information about the NumPy-Discussion