From b42370be0c5876887960ae0cdc535beae832c924 Mon Sep 17 00:00:00 2001 From: Skipper Seabold Date: Sun, 8 May 2011 14:16:25 -0400 Subject: [PATCH 1/2] Add not empty check to linalg.qr --- numpy/linalg/linalg.py | 1 + 1 file changed, 1 insertion(+) diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 36602e43e32f..5696c4476c29 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -625,6 +625,7 @@ def qr(a, mode='full'): """ a, wrap = _makearray(a) _assertRank2(a) + _assertNonEmpty(a) m, n = a.shape t, result_t = _commonType(a) a = _fastCopyAndTranspose(t, a) From e02d8f53ae4749000897dd41673de544a0f9dbc3 Mon Sep 17 00:00:00 2001 From: Skipper Seabold Date: Mon, 9 May 2011 17:15:53 -0400 Subject: [PATCH 2/2] Add test for QR on empty array --- numpy/linalg/tests/test_linalg.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py index 3bcdb5e12def..1f135fd4b5cf 100644 --- a/numpy/linalg/tests/test_linalg.py +++ b/numpy/linalg/tests/test_linalg.py @@ -430,6 +430,11 @@ def test_matrix_rank(): # works on scalar yield assert_equal, matrix_rank(1), 1 +@raises(linalg.LinAlgError) +def test_qr_empty(): + a = np.zeros((0,2)) + linalg.qr(a) + if __name__ == "__main__": run_module_suite()