Skip to content

Commit

Permalink
MAINT: special_matrices: add a note about handling of empty sequences
Browse files Browse the repository at this point in the history
Also pep8-ify the test.
  • Loading branch information
ev-br committed Apr 4, 2015
1 parent 4739653 commit d2537fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion scipy/linalg/special_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def block_diag(*arrs):
Parameters
----------
A, B, C, ... : array_like, up to 2-D
Input arrays. A 1-D array or array_like sequence of length `n`is
Input arrays. A 1-D array or array_like sequence of length `n` is
treated as a 2-D array with shape ``(1,n)``.
Returns
Expand All @@ -498,6 +498,8 @@ def block_diag(*arrs):
If all the input arrays are square, the output is known as a
block diagonal matrix.
Empty sequences (i.e., array-likes of zero size) are ignored.
Examples
--------
>>> from scipy.linalg import block_diag
Expand Down
10 changes: 8 additions & 2 deletions scipy/linalg/tests/test_special_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,14 @@ def test_no_args(self):

def test_empty_matrix_arg(self):
# regression test for gh-4596: check the shape of the result for empty matrix inputs
a = block_diag([[1, 0], [0, 1]], [], [[2, 3], [4, 5], [6, 7]])
assert_array_equal(a, [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 2, 3], [0, 0, 4, 5], [0, 0, 6, 7]])
a = block_diag([[1, 0], [0, 1]],
[],
[[2, 3], [4, 5], [6, 7]])
assert_array_equal(a, [[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 2, 3],
[0, 0, 4, 5],
[0, 0, 6, 7]])


class TestKron:
Expand Down

0 comments on commit d2537fa

Please sign in to comment.