[pypy-commit] pypy separate-applevel-numpy: merge in default

timo_jbo noreply at buildbot.pypy.org
Tue Oct 4 00:40:55 CEST 2011


Author: Timo Paulssen <timonator at perpetuum-immobile.de>
Branch: separate-applevel-numpy
Changeset: r47813:b528c5ddc7c1
Date: 2011-10-04 00:16 +0200
http://bitbucket.org/pypy/pypy/changeset/b528c5ddc7c1/

Log:	merge in default

diff --git a/pypy/module/_numpy/__init__.py b/pypy/module/_numpy/__init__.py
--- a/pypy/module/_numpy/__init__.py
+++ b/pypy/module/_numpy/__init__.py
@@ -24,6 +24,7 @@
         ("arcsin", "arcsin"),
         ("arctan", "arctan"),
         ("arcsinh", "arcsinh"),
+        ("arctanh", "arctanh"),
         ("copysign", "copysign"),
         ("cos", "cos"),
         ("divide", "divide"),
diff --git a/pypy/module/_numpy/interp_dtype.py b/pypy/module/_numpy/interp_dtype.py
--- a/pypy/module/_numpy/interp_dtype.py
+++ b/pypy/module/_numpy/interp_dtype.py
@@ -260,12 +260,12 @@
         return math.tan(v)
     @unaryop
     def arcsin(self, v):
-        if v < -1.0 or v > 1.0:
+        if not -1.0 <= v <= 1.0:
             return rfloat.NAN
         return math.asin(v)
     @unaryop
     def arccos(self, v):
-        if v < -1.0 or v > 1.0:
+        if not -1.0 <= v <= 1.0:
             return rfloat.NAN
         return math.acos(v)
     @unaryop
@@ -276,6 +276,14 @@
     def arcsinh(self, v):
         return math.asinh(v)
 
+    @unaryop
+    def arctanh(self, v):
+        if v == 1.0 or v == -1.0:
+            return math.copysign(rfloat.INFINITY, v)
+        if not -1.0 < v < 1.0:
+            return rfloat.NAN
+        return math.atanh(v)
+
 class IntegerArithmeticDtype(ArithmeticTypeMixin):
     _mixin_ = True
 
diff --git a/pypy/module/_numpy/interp_ufuncs.py b/pypy/module/_numpy/interp_ufuncs.py
--- a/pypy/module/_numpy/interp_ufuncs.py
+++ b/pypy/module/_numpy/interp_ufuncs.py
@@ -313,6 +313,7 @@
             ("arccos", "arccos", 1, {"promote_to_float": True}),
             ("arctan", "arctan", 1, {"promote_to_float": True}),
             ("arcsinh", "arcsinh", 1, {"promote_to_float": True}),
+            ("arctanh", "arctanh", 1, {"promote_to_float": True}),
         ]:
             self.add_ufunc(space, *ufunc_def)
 
diff --git a/pypy/module/_numpy/test/test_ufuncs.py b/pypy/module/_numpy/test/test_ufuncs.py
--- a/pypy/module/_numpy/test/test_ufuncs.py
+++ b/pypy/module/_numpy/test/test_ufuncs.py
@@ -307,6 +307,17 @@
             assert math.asinh(v) == arcsinh(v)
         assert math.isnan(arcsinh(float("nan")))
 
+    def test_arctanh(self):
+        import math
+        from numpy import arctanh
+
+        for v in [.99, .5, 0, -.5, -.99]:
+            assert math.atanh(v) == arctanh(v)
+        for v in [2.0, -2.0]:
+            assert math.isnan(arctanh(v))
+        for v in [1.0, -1.0]:
+            assert arctanh(v) == math.copysign(float("inf"), v)
+
     def test_reduce_errors(self):
         from _numpy import sin, add
 


More information about the pypy-commit mailing list