summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_index_tricks.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2018-10-11 06:24:51 -0700
committerGitHub <noreply@github.com>2018-10-11 06:24:51 -0700
commit76779d3c58e937cdc7495c131bcdbd40774edc8a (patch)
tree5c43f07e33ad5eff95ccd3f5183eadcaef317208 /numpy/lib/tests/test_index_tricks.py
parent9c4cb99f968ec6f33548ed1bfe04079f0f3932f7 (diff)
parenta2cdbfa8ffb848b5e1c3ec0c057000cf87e5964f (diff)
downloadnumpy-76779d3c58e937cdc7495c131bcdbd40774edc8a.tar.gz
Merge pull request #12137 from tylerjereddy/fill_diag_err_test
TST: error tests for fill_diagonal()
Diffstat (limited to 'numpy/lib/tests/test_index_tricks.py')
-rw-r--r--numpy/lib/tests/test_index_tricks.py13
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 aa3c7b8a4..53588f7a3 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)