diff options
author | David Cournapeau <cournape@gmail.com> | 2009-07-20 05:36:01 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2009-07-20 05:36:01 +0000 |
commit | 197d9411d78b405fa9fc9de90c29660af833185c (patch) | |
tree | 4d5bae53edaf2f45e1e57175990333bea395ba17 | |
parent | c041bd91885fb28fcce600cb66a77d6ae0493680 (diff) | |
download | numpy-197d9411d78b405fa9fc9de90c29660af833185c.tar.gz |
Add tests for hypot function.
-rw-r--r-- | numpy/core/tests/test_umath.py | 19 |
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) |