From a2cdbfa8ffb848b5e1c3ec0c057000cf87e5964f Mon Sep 17 00:00:00 2001 From: Tyler Reddy Date: Wed, 10 Oct 2018 14:39:42 -0700 Subject: TST: error tests for fill_diagonal() * add error handling tests for previously uncovered code in fill_diagonal() --- numpy/lib/tests/test_index_tricks.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'numpy/lib') diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py index 33b98629d..c6bcc0a86 100644 --- a/numpy/lib/tests/test_index_tricks.py +++ b/numpy/lib/tests/test_index_tricks.py @@ -336,6 +336,19 @@ class TestFillDiagonal(object): i = np.array([0, 1, 2]) assert_equal(np.where(a != 0), (i, i, i, i)) + def test_low_dim_handling(self): + # raise error with low dimensionality + a = np.zeros(3, int) + with assert_raises_regex(ValueError, "at least 2-d"): + fill_diagonal(a, 5) + + def test_hetero_shape_handling(self): + # raise error with high dimensionality and + # shape mismatch + a = np.zeros((3,3,7,3), int) + with assert_raises_regex(ValueError, "equal length"): + fill_diagonal(a, 2) + def test_diag_indices(): di = diag_indices(4) -- cgit v1.2.1