[Numpy-discussion] numpy.genfromtxt converters issue

Lluís xscript@gmx....
Sun Nov 14 14:30:50 CST 2010


Pierre GM writes:

> On Nov 11, 2010, at 8:31 PM, Lluís wrote:

>> Pierre GM writes:
>> 
>>> In practice, that's exactly what happens below the hood when
>>> genfromtxt tries to guess the output type of the converter. It tries a
>>> single value ('1'), fails, and decides that the result must be an
>>> object... Probably not the best strategy, as it crashes in your
>>> case. But yours is a buggy case anyway.
>> [...]
>>> Now, we can argue over the very last point: if both a converter and a
>>> dtype are specified, which one should take precedence?
>>> You have my opinion, let's hear yours.
>> 
>> What about delaying the calculation of converters?
>> Instead of using type
>> checks with fake data, 'StringConverter.update' could take an optional
>> argument 'imput_sample' (defaulting to "1") in order to perform its
>> checks.
>> 
>> Then, use real data from the first (non-comment, non-names) line of the
>> input file when calling 'StringConverter.update' in 'genfromtxt'.

> Mmh. That's an idea... Do you have a patch to suggest?

This will work as long as 'first_values' is assured to always contain
valid data and as long as its indexes are equivalent to those in
converters (which I simply haven't checked).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: numpy-#1665.patch
Type: text/x-diff
Size: 1654 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20101114/e7638211/attachment.bin 
-------------- next part --------------

apa!

-- 
 "And it's much the same thing with knowledge, for whenever you learn
 something new, the whole world becomes that much richer."
 -- The Princess of Pure Reason, as told by Norton Juster in The Phantom
 Tollbooth


More information about the NumPy-Discussion mailing list