File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,32 @@ def test_pymc_model(backend, gradient_backend):
31
31
trace .posterior .a # noqa: B018
32
32
33
33
34
+ @pytest .mark .pymc
35
+ @parameterize_backends
36
+ def test_low_rank (backend , gradient_backend ):
37
+ with pm .Model () as model :
38
+ pm .Normal ("a" )
39
+
40
+ compiled = nutpie .compile_pymc_model (
41
+ model , backend = backend , gradient_backend = gradient_backend
42
+ )
43
+ trace = nutpie .sample (compiled , chains = 1 , low_rank_modified_mass_matrix = True )
44
+ trace .posterior .a # noqa: B018
45
+
46
+
47
+ @pytest .mark .pymc
48
+ @parameterize_backends
49
+ def test_low_rank_half_normal (backend , gradient_backend ):
50
+ with pm .Model () as model :
51
+ pm .HalfNormal ("a" , shape = 13 )
52
+
53
+ compiled = nutpie .compile_pymc_model (
54
+ model , backend = backend , gradient_backend = gradient_backend
55
+ )
56
+ trace = nutpie .sample (compiled , chains = 1 , low_rank_modified_mass_matrix = True )
57
+ trace .posterior .a # noqa: B018
58
+
59
+
34
60
@pytest .mark .pymc
35
61
@parameterize_backends
36
62
def test_zero_size (backend , gradient_backend ):
Original file line number Diff line number Diff line change @@ -27,6 +27,23 @@ def test_stan_model():
27
27
trace .posterior .a # noqa: B018
28
28
29
29
30
+ @pytest .mark .stan
31
+ def test_stan_model_low_rank ():
32
+ model = """
33
+ data {}
34
+ parameters {
35
+ real a;
36
+ }
37
+ model {
38
+ a ~ normal(0, 1);
39
+ }
40
+ """
41
+
42
+ compiled_model = nutpie .compile_stan_model (code = model )
43
+ trace = nutpie .sample (compiled_model , low_rank_modified_mass_matrix = True )
44
+ trace .posterior .a # noqa: B018
45
+
46
+
30
47
@pytest .mark .stan
31
48
def test_empty ():
32
49
model = """
@@ -40,7 +57,7 @@ def test_empty():
40
57
"""
41
58
42
59
compiled_model = nutpie .compile_stan_model (code = model )
43
- trace = nutpie .sample (compiled_model ) # noqa: F841
60
+ nutpie .sample (compiled_model )
44
61
# TODO: Variable `a` is missing because of this bridgestan issue:
45
62
# https://github.com/roualdes/bridgestan/issues/278
46
63
# assert trace.posterior.a.shape == (0, 1000)
You can’t perform that action at this time.
0 commit comments