Re: [Numpy-discussion] Bug with mafromtxt

2009-01-26 Thread Pierre GM

On Jan 24, 2009, at 6:23 PM, Ryan May wrote:


 Ok, thanks.  I've dug a little further, and it seems like the  
 problem is that a
 column of all missing values ends up as a column of all None's.   
 When you create
 a (masked) array from a list of None's, you end up with an object  
 array.  On one
 hand I'd love for things to behave differently in this case, but on  
 the other I
 understand why things work this way.

Ryan,
Mind giving r6434 a try? As usual, don't hesitate to report any problem.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Bug with mafromtxt

2009-01-26 Thread Ryan May
Pierre GM wrote:
 On Jan 24, 2009, at 6:23 PM, Ryan May wrote:
 Ok, thanks.  I've dug a little further, and it seems like the  
 problem is that a
 column of all missing values ends up as a column of all None's.   
 When you create
 a (masked) array from a list of None's, you end up with an object  
 array.  On one
 hand I'd love for things to behave differently in this case, but on  
 the other I
 understand why things work this way.
 
 Ryan,
 Mind giving r6434 a try? As usual, don't hesitate to report any problem.

Works great! Thanks for the quick fix.  I had racked my brain on how to go about
fixing this cleanly, but this is far simpler than what I would have done.  It
makes sense, since all I really needed for the masked column was something
*other* than object.

Thanks a lot,

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Bug with mafromtxt

2009-01-24 Thread Ryan May
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
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Bug with mafromtxt

2009-01-24 Thread Pierre GM
Ryan,
Thanks for reporting. An idea would be to force the dtype of the  
masked column to the largest dtype of the other columns (in your  
example, that would be int). I'll try to see how easily it can be done  
early next week. Meanwhile, you can always give an explicit dtype at  
creation.

On Jan 24, 2009, at 5:58 PM, Ryan May wrote:

 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
 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Bug with mafromtxt

2009-01-24 Thread Ryan May
Pierre GM wrote:
 Ryan,
 Thanks for reporting. An idea would be to force the dtype of the  
 masked column to the largest dtype of the other columns (in your  
 example, that would be int). I'll try to see how easily it can be done  
 early next week. Meanwhile, you can always give an explicit dtype at  
 creation.

Ok, thanks.  I've dug a little further, and it seems like the problem is that a
column of all missing values ends up as a column of all None's.  When you create
a (masked) array from a list of None's, you end up with an object array.  On one
hand I'd love for things to behave differently in this case, but on the other I
understand why things work this way.

Ryan

 
 On Jan 24, 2009, at 5:58 PM, Ryan May wrote:
 
 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
 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion
 
 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion


-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion