From 1b3834d7b59da2e809d320992c632697355d63b6 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Fri, 12 Apr 2013 18:16:31 +0300 Subject: BUG: linalg: make umath_linalg to track errors from all inner loop iterations This ensures that the FP invalid flag always reflects the return code from LAPACK. Fixes a bug in 63a8aef81 where umath_linalg raises a warning only if the error occurs in the last iteration of the ufunc inner loop. --- numpy/linalg/tests/test_linalg.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'numpy/linalg/tests') diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py index 0a6f8f4ca..af9bf884d 100644 --- a/numpy/linalg/tests/test_linalg.py +++ b/numpy/linalg/tests/test_linalg.py @@ -654,5 +654,18 @@ def test_byteorder_check(): assert_array_equal(res, routine(sw_arr)) +def test_generalized_raise_multiloop(): + # It should raise an error even if the error doesn't occur in the + # last iteration of the ufunc inner loop + + invertible = np.array([[1, 2], [3, 4]]) + non_invertible = np.array([[1, 1], [1, 1]]) + + x = np.zeros([4, 4, 2, 2])[1::2] + x[...] = invertible + x[0,0] = non_invertible + + assert_raises(np.linalg.LinAlgError, np.linalg.inv, x) + if __name__ == "__main__": run_module_suite() -- cgit v1.2.1