diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2016-03-13 13:47:35 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2016-03-13 20:06:06 -0600 |
commit | 204308463955f6604356887e3043743dc163d391 (patch) | |
tree | afec8902461c077e7884d3059747e547c7d3de12 /numpy/lib/tests/test_function_base.py | |
parent | d92ff4cdd1fc3608e39ffbe119ecbb520b678f3e (diff) | |
download | numpy-204308463955f6604356887e3043743dc163d391.tar.gz |
TST: Check that result of corrcoef are clipped.
This doesn't actually test much, as we don't have any inputs where that
was not already the case. But at least it is there and perhaps a fuzz
test can be added at a later date.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 943544dd5..da2d77e07 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1650,8 +1650,13 @@ class TestCorrCoef(TestCase): [[1., -1.], [-1., 1.]]) def test_simple(self): - assert_almost_equal(corrcoef(self.A), self.res1) - assert_almost_equal(corrcoef(self.A, self.B), self.res2) + tgt1 = corrcoef(self.A) + assert_almost_equal(tgt1, self.res1) + assert_(np.all(np.abs(tgt1) <= 1.0)) + + tgt2 = corrcoef(self.A, self.B) + assert_almost_equal(tgt2, self.res2) + assert_(np.all(np.abs(tgt2) <= 1.0)) def test_ddof(self): # ddof raises DeprecationWarning @@ -1677,7 +1682,10 @@ class TestCorrCoef(TestCase): def test_complex(self): x = np.array([[1, 2, 3], [1j, 2j, 3j]]) - assert_allclose(corrcoef(x), np.array([[1., -1.j], [1.j, 1.]])) + res = corrcoef(x) + tgt = np.array([[1., -1.j], [1.j, 1.]]) + assert_allclose(res, tgt) + assert_(np.all(np.abs(res) <= 1.0)) def test_xy(self): x = np.array([[1, 2, 3]]) @@ -1698,6 +1706,7 @@ class TestCorrCoef(TestCase): with np.errstate(all='raise'): c = corrcoef(x) assert_array_almost_equal(c, np.array([[1., -1.], [-1., 1.]])) + assert_(np.all(np.abs(c) <= 1.0)) class TestCov(TestCase): |