[Biopython-dev] float('nan') fails on Python 2.5 on Windows (PAML)
Peter Cock
p.j.a.cock at googlemail.com
Thu Jul 21 16:48:38 EDT 2011
On Sun, Jun 5, 2011 at 10:51 PM, Peter wrote:
> Hi all,
>
> As explained in PEP 754, prior to Python 2.6 float('inf'), float('-inf')
> and also float('nan') were passed to the underlying C library, which
> may or may not return the IEEE special floating point value for
> infinity, minus infinity or nan. See:
> http://www.python.org/dev/peps/pep-0754/
>
> This is the root cause of this unit test failure on Windows Python 2.5,
> ...
The related problem of float("nan") on Python 2.5 or older on
Windows is the cause of this problem in the new PAML code too:
http://testing.open-bio.org/biopython/builders/Windows%20XP%20-%20Python%202.5/builds/229/steps/shell/logs/stdio
ValueError: invalid literal for float(): nan
I guess _parse_codeml.py might need something like this:
try:
float("nan")
_float = float
except ValueError:
def _float(txt):
try:
return float(text)
except ValueError, e:
if txt=="nan":
return XXX
else:
raise e
And then use the nan safe _float function in the parser.
Unless anyone has a nicer solution?
Peter
More information about the Biopython-dev
mailing list