Re: [Numpy-discussion] masked record arrays
Pierre GM-2 wrote: Mmh. With a recent (1.3) version of numpy, you should already be able to mask individual fields of a structured array without problems. If you need fields to be accessed as attributes the np.recarray way, you can give numpy.ma.mrecords.MaskedRecords a try. It's been a while I haven't touched it, so you may run into the occasional bug. FYI, I'm not a big fan of record arrays and tend to prefer structured ones... What two implementations were you talking about ? In any case, feel free to try and please, report any issue you run into with MaskedRecords. Cheers Thanks for the advice! I'm somewhat confused by the difference between structured and record arrays. My understanding is that record arrays allow you to access fields by attribute (e.g. r.field_name), but I imagine that there are much more fundamental differences for the two to be treated separately in numpy. I find the numpy documentation somewhat confusing in that respect - if you have a look at this page http://docs.scipy.org/doc/numpy/user/basics.rec.html I think the 'aka record arrays' is especially confusing as this would suggest the two are the same. So is there good information anywhere about what exactly are the differences between the two? This page is also confusing: http://docs.scipy.org/doc/numpy/reference/generated/numpy.recarray.html as to me Construct an ndarray that allows field access using attributes suggests that all a recarray is is an ndarray/structured array with overloaded __getattr__/__setattr__ methods. Is that all recarrays are? If so, why was a completely separate package developed for masked record arrays - can one not just use masked structured arrays and overload getattr/setattr? Cheers, Thomas -- View this message in context: http://old.nabble.com/masked-record-arrays-tp26237612p26247808.html Sent from the Numpy-discussion mailing list archive at Nabble.com. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] masked record arrays
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 allow you to access fields by attribute (e.g. r.field_name), but I imagine that 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 http://docs.scipy.org/doc/numpy/user/basics.rec.html 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 confusing: http://docs.scipy.org/doc/numpy/reference/generated/ numpy.recarray.html as to me Construct an ndarray that allows field access using attributes suggests that all a recarray is is an ndarray/structured array with overloaded __getattr__/__setattr__ methods. Is that all recarrays are? Yep. If so, why was a completely separate package developed for masked record arrays - can one not just use masked structured arrays and overload getattr/setattr? 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. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion