Skip to content

Commit

Permalink
add test for ndim check
Browse files Browse the repository at this point in the history
  • Loading branch information
aerubanov committed Jul 26, 2021
1 parent 5ddd1d5 commit c89dad2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pymc3/tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3085,7 +3085,7 @@ def test_car_logp(sparse, size):
[False, True],
ids=str,
)
def test_car_symmetry_check(sparse):
def test_car_matrix_check(sparse):
"""
Tests the check of W matrix symmetry in CARRV.make_node.
"""
Expand All @@ -3104,9 +3104,16 @@ def test_car_symmetry_check(sparse):
W = aesara.sparse.csr_from_dense(W)

car_dist = CAR.dist(mu, W, alpha, tau)
with pytest.raises(AssertionError):
with pytest.raises(AssertionError, match="W must be a symmetric adjacency matrix"):
logp(car_dist, xs).eval()

# W.ndim != 2
if not sparse:
W = np.array([0.0, 1.0, 2.0, 0.0])
W = aesara.tensor.as_tensor_variable(W)
with pytest.raises(ValueError, match="W must be a matrix"):
car_dist = CAR.dist(mu, W, alpha, tau)


class TestBugfixes:
@pytest.mark.parametrize("dist_cls,kwargs", [(MvNormal, dict()), (MvStudentT, dict(nu=2))])
Expand Down

0 comments on commit c89dad2

Please sign in to comment.