summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2009-07-20 05:36:01 +0000
committerDavid Cournapeau <cournape@gmail.com>2009-07-20 05:36:01 +0000
commit197d9411d78b405fa9fc9de90c29660af833185c (patch)
tree4d5bae53edaf2f45e1e57175990333bea395ba17 /numpy
parentc041bd91885fb28fcce600cb66a77d6ae0493680 (diff)
downloadnumpy-197d9411d78b405fa9fc9de90c29660af833185c.tar.gz
Add tests for hypot function.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/tests/test_umath.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index 212e3b597..238c06886 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -199,6 +199,25 @@ class TestExpm1(TestCase):
assert_almost_equal(ncu.expm1(0.2), ncu.exp(0.2)-1)
assert_almost_equal(ncu.expm1(1e-6), ncu.exp(1e-6)-1)
+class TestHypot(TestCase, object):
+ def test_simple(self):
+ assert_almost_equal(ncu.hypot(1, 1), ncu.sqrt(2))
+ assert_almost_equal(ncu.hypot(0, 0), 0)
+
+def assert_hypot_isnan(x, y):
+ assert np.isnan(ncu.hypot(x, y))
+
+def assert_hypot_isinf(x, y):
+ assert np.isinf(ncu.hypot(x, y))
+
+def test_hypot_special_values():
+ yield assert_hypot_isnan, np.nan, np.nan
+ yield assert_hypot_isnan, np.nan, 1
+ yield assert_hypot_isinf, np.nan, np.inf
+ yield assert_hypot_isinf, np.inf, np.nan
+ yield assert_hypot_isinf, np.inf, 0
+ yield assert_hypot_isinf, 0, np.inf
+
class TestMaximum(TestCase):
def test_reduce_complex(self):
assert_equal(np.maximum.reduce([1,2j]),1)