[pypy-commit] pypy default: numpy: Added ufuncs for sinh, cosh, tanh
amauryfa
noreply at buildbot.pypy.org
Sat Feb 18 16:07:03 CET 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch:
Changeset: r52606:41b77bbdfddd
Date: 2012-02-18 16:05 +0100
http://bitbucket.org/pypy/pypy/changeset/41b77bbdfddd/
Log: numpy: Added ufuncs for sinh, cosh, tanh
diff --git a/pypy/module/micronumpy/__init__.py b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -71,6 +71,7 @@
("arctanh", "arctanh"),
("copysign", "copysign"),
("cos", "cos"),
+ ("cosh", "cosh"),
("divide", "divide"),
("true_divide", "true_divide"),
("equal", "equal"),
@@ -90,9 +91,11 @@
("reciprocal", "reciprocal"),
("sign", "sign"),
("sin", "sin"),
+ ("sinh", "sinh"),
("subtract", "subtract"),
('sqrt', 'sqrt'),
("tan", "tan"),
+ ("tanh", "tanh"),
('bitwise_and', 'bitwise_and'),
('bitwise_or', 'bitwise_or'),
('bitwise_xor', 'bitwise_xor'),
diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -435,6 +435,9 @@
("arcsin", "arcsin", 1, {"promote_to_float": True}),
("arccos", "arccos", 1, {"promote_to_float": True}),
("arctan", "arctan", 1, {"promote_to_float": True}),
+ ("sinh", "sinh", 1, {"promote_to_float": True}),
+ ("cosh", "cosh", 1, {"promote_to_float": True}),
+ ("tanh", "tanh", 1, {"promote_to_float": True}),
("arcsinh", "arcsinh", 1, {"promote_to_float": True}),
("arctanh", "arctanh", 1, {"promote_to_float": True}),
]:
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -310,6 +310,33 @@
b = arctan(a)
assert math.isnan(b[0])
+ def test_sinh(self):
+ import math
+ from _numpypy import array, sinh
+
+ a = array([-1, 0, 1, float('inf'), float('-inf')])
+ b = sinh(a)
+ for i in range(len(a)):
+ assert b[i] == math.sinh(a[i])
+
+ def test_cosh(self):
+ import math
+ from _numpypy import array, cosh
+
+ a = array([-1, 0, 1, float('inf'), float('-inf')])
+ b = cosh(a)
+ for i in range(len(a)):
+ assert b[i] == math.cosh(a[i])
+
+ def test_tanh(self):
+ import math
+ from _numpypy import array, tanh
+
+ a = array([-1, 0, 1, float('inf'), float('-inf')])
+ b = tanh(a)
+ for i in range(len(a)):
+ assert b[i] == math.tanh(a[i])
+
def test_arcsinh(self):
import math
from _numpypy import arcsinh
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -489,6 +489,18 @@
return math.atan(v)
@simple_unary_op
+ def sinh(self, v):
+ return math.sinh(v)
+
+ @simple_unary_op
+ def cosh(self, v):
+ return math.cosh(v)
+
+ @simple_unary_op
+ def tanh(self, v):
+ return math.tanh(v)
+
+ @simple_unary_op
def arcsinh(self, v):
return math.asinh(v)
More information about the pypy-commit
mailing list