[pypy-commit] pypy default: Test and fix for 'math.fsum([nan])'. It's a typo when copying from CPython's mathmodule.c.
arigo
noreply at buildbot.pypy.org
Tue Jun 23 13:20:50 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r78258:459148974175
Date: 2015-06-23 13:20 +0200
http://bitbucket.org/pypy/pypy/changeset/459148974175/
Log: Test and fix for 'math.fsum([nan])'. It's a typo when copying from
CPython's mathmodule.c.
diff --git a/pypy/module/math/interp_math.py b/pypy/module/math/interp_math.py
--- a/pypy/module/math/interp_math.py
+++ b/pypy/module/math/interp_math.py
@@ -345,7 +345,7 @@
else:
partials.append(v)
if special_sum != 0.0:
- if rfloat.isnan(special_sum):
+ if rfloat.isnan(inf_sum):
raise OperationError(space.w_ValueError, space.wrap("-inf + inf"))
return space.wrap(special_sum)
hi = 0.0
diff --git a/pypy/module/math/test/test_math.py b/pypy/module/math/test/test_math.py
--- a/pypy/module/math/test/test_math.py
+++ b/pypy/module/math/test/test_math.py
@@ -1,5 +1,6 @@
from __future__ import with_statement
+import py
from pypy.interpreter.function import Function
from pypy.interpreter.gateway import BuiltinCode
from pypy.module.math.test import test_direct
@@ -96,6 +97,10 @@
([2.**n - 2.**(n+50) + 2.**(n+52) for n in range(-1074, 972, 2)] +
[-2.**1022],
float.fromhex('0x1.5555555555555p+970')),
+ # infinity and nans
+ ([float("inf")], float("inf")),
+ ([float("-inf")], float("-inf")),
+ ([float("nan")], float("nan")),
]
for i, (vals, expected) in enumerate(test_values):
@@ -107,7 +112,8 @@
except ValueError:
py.test.fail("test %d failed: got ValueError, expected %r "
"for math.fsum(%.100r)" % (i, expected, vals))
- assert actual == expected
+ assert actual == expected or (
+ math.isnan(actual) and math.isnan(expected))
def test_factorial(self):
import math
More information about the pypy-commit
mailing list