Skip to content

Commit

Permalink
BUG: fixing issue scipy#3111
Browse files Browse the repository at this point in the history
  • Loading branch information
perimosocordiae authored and André Gaul committed Dec 4, 2013
1 parent b395c77 commit b21037e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scipy/sparse/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,16 @@ def bmat(blocks, format=None, dtype=None):
# check for fast path cases
if (N == 1 and format in (None, 'csr')
and all(isinstance(b, csr_matrix) for b in blocks.flat)):
return _compressed_sparse_stack(blocks[:,0], 0)
A = _compressed_sparse_stack(blocks[:,0], 0)
if dtype is not None:
A = A.astype(dtype)
return A
elif (M == 1 and format in (None, 'csc')
and all(isinstance(b, csc_matrix) for b in blocks.flat)):
return _compressed_sparse_stack(blocks[0,:], 1)
A = _compressed_sparse_stack(blocks[0,:], 1)
if dtype is not None:
A = A.astype(dtype)
return A

block_mask = np.zeros(blocks.shape, dtype=np.bool)
brow_lengths = np.zeros(blocks.shape[0], dtype=np.intc)
Expand Down

0 comments on commit b21037e

Please sign in to comment.