[Numpy-discussion] Bug with mafromtxt

Ryan May rmay31@gmail....
Sat Jan 24 16:58:12 CST 2009


Pierre,

I've found what I consider to be a bug in the new mafromtxt (though apparently it
existed in earlier versions as well).  If you have an entire column of data in a
file that contains only masked data, and try to get mafromtxt to automatically
choose the dtype, the dtype gets selected to be object type.  In this case, I'd
think the better behavior would be float, but I'm not sure how hard it would be
to make this the case.  Here's a test case:

import numpy as np
from StringIO import StringIO
s = StringIO('1 2 3\n4 5 6\n')
a = np.mafromtxt(s, missing='2,5', dtype=None)
print a.dtype

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma


More information about the Numpy-discussion mailing list