Skip to content

Commit

Permalink
Merge pull request #13406 from ashutoshvarma/master
Browse files Browse the repository at this point in the history
TST: add error handling tests for sparse BSR ctor
  • Loading branch information
tylerjereddy committed Jan 21, 2021
2 parents 476c6de + 46de4f0 commit 0ec3c2f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scipy/sparse/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4309,6 +4309,26 @@ def test_constructor4(self):
indices = np.arange(n, dtype=np.int32)
bsr_matrix((data, indices, indptr), blocksize=(n, 1), copy=False)

def test_constructor5(self):
# check for validations introduced in gh-13400
n = 8
data_1dim = np.ones(n)
data = np.ones((n, n, n))
indptr = np.array([0, n])
indices = np.arange(n)

with assert_raises(ValueError):
# data ndim check
bsr_matrix((data_1dim, indices, indptr))

with assert_raises(ValueError):
# invalid blocksize
bsr_matrix((data, indices, indptr), blocksize=(1, 1, 1))

with assert_raises(ValueError):
# mismatching blocksize
bsr_matrix((data, indices, indptr), blocksize=(1, 1))

def test_bsr_tocsr(self):
# check native conversion from BSR to CSR
indptr = array([0, 2, 2, 4])
Expand Down

0 comments on commit 0ec3c2f

Please sign in to comment.