[Biopython-dev] float('inf') or float('-inf')
Peter Cock
p.j.a.cock at googlemail.com
Sun Jun 5 21:51:26 UTC 2011
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,
http://testing.open-bio.org/biopython/builders/Windows%20XP%20-%20Python%202.5/builds/224/steps/shell/logs/stdio
======================================================================
ERROR: Test a simple model with 2 states and 2 symbols.
----------------------------------------------------------------------
Traceback (most recent call last):
File "c:\repositories\BuildBot\win25\build\Tests\test_HMMGeneral.py",
line 260, in test_simple_hmm
viterbi = model.viterbi(observed_emissions, NumberAlphabet)
File "c:\repositories\BuildBot\win25\build\build\lib.win32-2.5\Bio\HMM\MarkovModel.py",
line 499, in viterbi
log_initial = self._log_transform(self.initial_prob)
File "c:\repositories\BuildBot\win25\build\build\lib.win32-2.5\Bio\HMM\MarkovModel.py",
line 598, in _log_transform
neg_inf = float("-inf")
ValueError: invalid literal for float(): -inf
and similarly on Windows Python 2.4,
http://testing.open-bio.org/biopython/builders/Windows%20XP%20-%20Python%202.4/builds/226/steps/shell/logs/stdio
This test failure is a result of me committing Walter Gillett's
fix to Txt Bio/HMM/MarkovModel.py last week:
https://github.com/biopython/biopython/commit/152f469179d4a142858a04c02169f8d1fc5f8c83
We would have spotted this earlier, but the Windows buildslave
machine has been in use by a new staff member (a temporary
arrangement). I guess we need more volunteer buildslave
machines...
Based on the PEP 754 example, 1E400 may work instead:
try:
neg_inf = float("-inf")
except ValueError:
neg_inf = -1E400
I'll try to test this on the machine later in the week when I get
a chance. If anyone else has Python 2.4 or 2.5 on Windows
and wants to look at this now, please go ahead.
Regards,
Peter
More information about the Biopython-dev
mailing list