[Bioperl-l] evalues/floating point tests
cjfields at illinois.edu
Sat Jan 17 21:53:00 UTC 2009
I've noticed an odd issue when testing BioPerl on WinXP yesterday
which doesn't appear to be popping up anywhere else. When comparing
floating point numbers, several tests fail like the following:
# Failed test at t\SearchIO\blast_pull.t line 40.
# got: '1e-23'
# expected: '1e-023'
# Failed test at t\SearchIO\blast_pull.t line 67.
# got: '6e-59'
# expected: '6e-059'
These are generally in lines like (for the example above)
is $result->get_parameter('expect'), 1e-23;
I'm adding a method to Bio::Root::Test for comparing two floating
point numbers based on equality:
float_eq $float1, $float2, $message;
This basically wraps is() but runs both values through 'sprintf("%g",
$foo)' prior to the comparison; it has a prototype requiring two
values to be passed and an optional message. Any objections to the
method name or adding this in? I've already converted many of the
tests in t/SearchIO over but wanted to pass it by the group prior to
an actual commit.
More information about the Bioperl-l