Skip to content

Commit 1558472

Browse files
committed
Parametrize the posdef_symmetric test
1 parent 905bc42 commit 1558472

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

pymc/tests/distributions/test_multivariate.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,26 +1877,19 @@ def test_car_rng_fn(sparse):
18771877
assert p > delta
18781878

18791879

1880-
def test_posdef_symmetric1():
1881-
data = np.array([[1.0, 0], [0, 1]], dtype=aesara.config.floatX)
1882-
assert posdef(data) == 1
1883-
1884-
1885-
def test_posdef_symmetric2():
1886-
data = np.array([[1.0, 2], [2, 1]], dtype=aesara.config.floatX)
1887-
assert posdef(data) == 0
1888-
1889-
1890-
def test_posdef_symmetric3():
1891-
"""The test return 0 if the matrix has 0 eigenvalue.
1880+
@pytest.mark.parametrize(
1881+
"matrix, result",
1882+
[
1883+
([[1.0, 0], [0, 1]], 1),
1884+
([[1.0, 2], [2, 1]], 0),
1885+
([[1.0, 1], [1, 1]], 0),
1886+
([[1, 0.99, 1], [0.99, 1, 0.999], [1, 0.999, 1]], 0),
1887+
],
1888+
)
1889+
def test_posdef_symmetric(matrix, result):
1890+
"""The test returns 0 if the matrix has 0 eigenvalue.
18921891
18931892
Is this correct?
18941893
"""
1895-
data = np.array([[1.0, 1], [1, 1]], dtype=aesara.config.floatX)
1896-
assert posdef(data) == 0
1897-
1898-
1899-
def test_posdef_symmetric4():
1900-
d = np.array([[1, 0.99, 1], [0.99, 1, 0.999], [1, 0.999, 1]], aesara.config.floatX)
1901-
1902-
assert posdef(d) == 0
1894+
data = np.array(matrix, dtype=aesara.config.floatX)
1895+
assert posdef(data) == result

0 commit comments

Comments
 (0)