[pypy-commit] pypy py3.5: math.inf, math.nan

arigo pypy.commits at gmail.com
Tue Nov 1 05:37:23 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r88013:53911f563c71
Date: 2016-11-01 10:36 +0100
http://bitbucket.org/pypy/pypy/changeset/53911f563c71/

Log:	math.inf, math.nan

diff --git a/pypy/module/math/__init__.py b/pypy/module/math/__init__.py
--- a/pypy/module/math/__init__.py
+++ b/pypy/module/math/__init__.py
@@ -11,6 +11,8 @@
     interpleveldefs = {
        'e'              : 'interp_math.get(space).w_e',
        'pi'             : 'interp_math.get(space).w_pi',
+       'inf'            : 'interp_math.get(space).w_inf',
+       'nan'            : 'interp_math.get(space).w_nan',
        'pow'            : 'interp_math.pow',
        'cosh'           : 'interp_math.cosh',
        'copysign'       : 'interp_math.copysign',
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
@@ -10,6 +10,8 @@
     def __init__(self, space):
         self.w_e = space.wrap(math.e)
         self.w_pi = space.wrap(math.pi)
+        self.w_inf = space.wrap(rfloat.INFINITY)
+        self.w_nan = space.wrap(rfloat.NAN)
 def get(space):
     return space.fromcache(State)
 
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
@@ -369,3 +369,9 @@
         assert math.gcd(-4, -10) == 2
         assert math.gcd(0, -10) == 10
         assert math.gcd(0, 0) == 0
+
+    def test_inf_nan(self):
+        import math
+        assert math.isinf(math.inf)
+        assert math.inf > -math.inf
+        assert math.isnan(math.nan)


More information about the pypy-commit mailing list