diff options
author | Tyler Reddy <tyler.je.reddy@gmail.com> | 2018-10-10 14:39:42 -0700 |
---|---|---|
committer | Tyler Reddy <tyler.je.reddy@gmail.com> | 2018-10-10 14:39:42 -0700 |
commit | a2cdbfa8ffb848b5e1c3ec0c057000cf87e5964f (patch) | |
tree | e9f02b8c862d169085285ef3fd7dcdae3a97be04 /numpy/lib/tests/test_index_tricks.py | |
parent | 2ed08ba2ec29a8ef5fb60fa1a17a3d9366ae6c5d (diff) | |
download | numpy-a2cdbfa8ffb848b5e1c3ec0c057000cf87e5964f.tar.gz |
TST: error tests for fill_diagonal()
* add error handling tests for previously
uncovered code in fill_diagonal()
Diffstat (limited to 'numpy/lib/tests/test_index_tricks.py')
-rw-r--r-- | numpy/lib/tests/test_index_tricks.py | 13 |
1 files changed, 13 insertions, 0 deletions
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) |