From: Pierre GM <pgm...@ma...> - 2006-10-23 12:52:28
|
Folks, I updated the alternative implementation of MaskedArray on the wiki, mainly to correct a couple of bugs. (http://projects.scipy.org/scipy/numpy/wiki/MaskedArray) In addition, I attached another file, maskedrecordarray, which introduce a new class, MaskedRecord, as a subclass of recarray and MaskedArray. An instance of this class accepts a recarray as data, and uses two masks: the 'recordmask' has as many entries as records in the array, each entry with the same fields as a record, but of boolean types, indicating whether a field is masked or not; an entry is flagged as masked in the 'mask' array if at least one field is masked. The 'mask' object is introduced mostly for compatibilty with MaskedArray, only 'recordmask' is really useful. A few examples in the file should give you an idea of what can be done. In particular, you can define a new maskedrecord array as simply as ; a = masked_record([('Alan',29,200.), ('Bill',31,260.0)], dtype=[('name','S30'),('age',int_),('weight',float_)], mask=[(1,0,0), (0,0,0)]) Note that maskedrecordarray is still quite experimental. As I'm not a regular user of records, I don't really know what should be implemented... The file can be accessed at http://projects.scipy.org/scipy/numpy/attachment/wiki/MaskedArray/maskedrecordarray.py Once again, I need your comments and suggestions ! Thanks. Pierre |