diff options
author | Simon Gibbons <simongibbons@gmail.com> | 2016-02-24 20:44:39 +0000 |
---|---|---|
committer | Simon Gibbons <simongibbons@gmail.com> | 2016-02-29 17:09:15 +0000 |
commit | 3fdf3270e6f47e65d8a8b4d995fc21f9b64650ee (patch) | |
tree | a6a7bf8de4ad3291be6048a9377226cdbe7bb273 /numpy/lib/tests/test_financial.py | |
parent | 1bd18cd7ea1ed83243777c1f52f369dfb9048e6c (diff) | |
download | numpy-3fdf3270e6f47e65d8a8b4d995fc21f9b64650ee.tar.gz |
BUG: np.irr should return NaN if there are no real solutions
Diffstat (limited to 'numpy/lib/tests/test_financial.py')
-rw-r--r-- | numpy/lib/tests/test_financial.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_financial.py b/numpy/lib/tests/test_financial.py index baa785424..cc8ba55e5 100644 --- a/numpy/lib/tests/test_financial.py +++ b/numpy/lib/tests/test_financial.py @@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function import numpy as np from numpy.testing import ( run_module_suite, TestCase, assert_, assert_almost_equal, - assert_allclose + assert_allclose, assert_equal ) @@ -26,6 +26,11 @@ class TestFinancial(TestCase): v = [-5, 10.5, 1, -8, 1] assert_almost_equal(np.irr(v), 0.0886, 2) + # Test that if there is no solution then np.irr returns nan + # Fixes gh-6744 + v = [-1, -2, -3] + assert_equal(np.irr(v), np.nan) + def test_pv(self): assert_almost_equal(np.pv(0.07, 20, 12000, 0), -127128.17, 2) |