[Numpy-discussion] More loadtxt() changes

Ryan May rmay31@gmail....
Tue Nov 25 21:02:24 CST 2008


Pierre GM wrote:
> Ryan,
> Quick comments:
> 
> * I already have some unittests for StringConverter, check the file I 
> attach.

Ok, great.

> * Your str2bool will probably mess things up in upgrade compared to the 
> one JDH had written (the one I send you): you don't wanna use 
> int(bool(value)), as it'll always give you 0 or 1 when you might need a 
> ValueError

Ok, I wasn't sure.  I was trying to merge what the old code used with 
the new str2bool you supplied.  That's probably not all that necessary.

> * Your locked version of update won't probably work either, as you force 
> the converter to output a string (you set the status to largest 
> possible, that's the one that outputs strings). Why don't you set the 
> status to the current one (make a tmp one if needed).

Looking at the code, it looks like mapper is only used in the upgrade() 
method. My goal by setting status to the largest possible is to lock the 
converter to the supplied function.  That way for the user supplied 
converters, the StringConverter doesn't try to upgrade away from it.  My 
thinking was that if the user supplied converter function fails, the 
user should know. (Though I got this wrong the first time.)

> * I'd probably get rid of StringConverter._get_from_dtype, as it is not 
> needed outside the __init__. You may wanna stick to the original __init__.

Done.

Ryan

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


More information about the Numpy-discussion mailing list