[SciPy-User] problems with masked arrays

Rob Felty robfelty@gmail....
Tue Oct 6 18:17:42 CDT 2009


I am trying to create an array which contains a mixture of strings, floats,
and ints. However, some of the int and float values are missing. It seems
that I should be able to use a masked array to do this, but I have been
unable to get it to work quite right. If I specify the dtype for each column
as a string, then it works. If I try to specify a column as an int, and
there is a missing value. It does not work. Here is minimal example
import numpy.ma as ma
test = [('', '3-D', 7333, '', '', '', '', '', 'Tridi', '', '', 'GOOGLE',
''), (4, 'a', 1267005, 3, 1, "'1", '[VV]', '[eI]', '@', 7.0, 7.0, 'HML',
'@')]
test_mask = [(True, False, False, True, True, True, True, True, False, True,
True, False, True), (False, False, False, False, False, False, False, False,
False, False, False, False, False)]

# this does not work, where I specify 'id' as an int
celex_array = ma.array(celex, dtype=[('id',int),('orth', 'a53'), ('freq',
'i8'), ('lemmaID', 'a53'), ('phonCount', 'a53'),  ('phonOrig', 'a53'),
('CV', 'a53'), ('phonSyl', 'a53'), ('XCRP', 'a53'), ('fam', 'a53'), ('dens',
'a53'),  ('source', 'a53'), ('hmlSyl', 'a53')],mask=celex_mask)

#this does work
celex_array = ma.array(celex, dtype=[('id','a53'),('orth', 'a53'), ('freq',
'i8'), ('lemmaID', 'a53'), ('phonCount', 'a53'),  ('phonOrig', 'a53'),
('CV', 'a53'), ('phonSyl', 'a53'), ('XCRP', 'a53'), ('fam', 'a53'), ('dens',
'a53'),  ('source', 'a53'), ('hmlSyl', 'a53')],mask=celex_mask)

Thanks in advance for any suggestions.

Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20091006/2963a736/attachment.html 


More information about the SciPy-User mailing list