From 69c33bf74bcdc1d9781bd5db27f942f6d676c032 Mon Sep 17 00:00:00 2001 From: Frederic Date: Mon, 11 Jun 2012 16:23:17 -0400 Subject: fix the wrapping problem of fill_diagonal with tall matrix. --- numpy/lib/tests/test_index_tricks.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'numpy/lib/tests/test_index_tricks.py') diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py index 2c6500a57..aaedd83ea 100644 --- a/numpy/lib/tests/test_index_tricks.py +++ b/numpy/lib/tests/test_index_tricks.py @@ -158,6 +158,28 @@ def test_fill_diagonal(): array([[5, 0, 0], [0, 5, 0], [0, 0, 5]])) + #Test tall matrix + a = zeros((10, 3),int) + fill_diagonal(a, 5) + yield (assert_array_equal, a, + array([[5, 0, 0], + [0, 5, 0], + [0, 0, 5], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0], + [0, 0, 0]])) + + #Test wide matrix + a = zeros((3, 10),int) + fill_diagonal(a, 5) + yield (assert_array_equal, a, + array([[5, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 5, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 5, 0, 0, 0, 0, 0, 0, 0]])) # The same function can operate on a 4-d array: a = zeros((3, 3, 3, 3), int) -- cgit v1.2.1