numpy: handling float('NaN') different in XP vs. Linux
John Machin
sjmachin at lexicon.net
Sat Jun 14 03:58:14 EDT 2008
On Jun 14, 3:33 pm, "John [H2O]" <washa... at gmail.com> wrote:
> John Machin wrote:
>
> > Avoid impolite astonishment; RTFloatingM instead:
> > """
>
> > HTH,
> > John
> > --
>
> I guess the key here is that it is not an issue with Python, but C... can I
> change 'the underlying C code?'
The underlying C code for the Windows C RTL is probably on a server in
a bunker in Redmond WA ... good luck :-)
Perhaps you could start lashing up something along the lines that Dan
mentioned, e.g.
floated = {
'NaN': 1e1000 / 1e1000,
'Inf': whatever,
}.get
def myfloat(s):
try:
return float(s)
except:
value = floated(s)
if value is not None:
raise
return value
Then when/if your mapping has enough entries to make it worthwhile,
you could maybe suggest that this be done in Numpy or in the Python
core.
Cheers,
John
More information about the Python-list
mailing list