@@ -87,6 +87,7 @@ def test_laplace_only_fit():
87
87
idata = pmx .fit (
88
88
method = "laplace" ,
89
89
vars = vars ,
90
+ draws = None ,
90
91
model = m ,
91
92
random_seed = 173300 ,
92
93
)
@@ -99,3 +100,41 @@ def test_laplace_only_fit():
99
100
100
101
assert np .allclose (idata .fit ["mean_vector" ].values , bda_map )
101
102
assert np .allclose (idata .fit ["covariance_matrix" ].values , bda_cov , atol = 1e-4 )
103
+
104
+
105
+ @pytest .mark .filterwarnings (
106
+ "ignore:Model.model property is deprecated. Just use Model.:FutureWarning" ,
107
+ "ignore:hessian will stop negating the output in a future version of PyMC.\n "
108
+ + "To suppress this warning set `negate_output=False`:FutureWarning" ,
109
+ )
110
+ def test_laplace_subset_of_rv (recwarn ):
111
+
112
+ # Example originates from Bayesian Data Analyses, 3rd Edition
113
+ # By Andrew Gelman, John Carlin, Hal Stern, David Dunson,
114
+ # Aki Vehtari, and Donald Rubin.
115
+ # See section. 4.1
116
+
117
+ y = np .array ([2642 , 3503 , 4358 ], dtype = np .float64 )
118
+ n = y .size
119
+
120
+ with pm .Model () as m :
121
+ logsigma = pm .Uniform ("logsigma" , 1 , 100 )
122
+ mu = pm .Uniform ("mu" , - 10000 , 10000 )
123
+ yobs = pm .Normal ("y" , mu = mu , sigma = pm .math .exp (logsigma ), observed = y )
124
+ vars = [mu ]
125
+
126
+ idata = pmx .fit (
127
+ method = "laplace" ,
128
+ vars = vars ,
129
+ draws = None ,
130
+ model = m ,
131
+ random_seed = 173300 ,
132
+ )
133
+
134
+ assert len (recwarn ) == 4
135
+ w = recwarn .pop (UserWarning )
136
+ assert issubclass (w .category , UserWarning )
137
+ assert (
138
+ str (w .message )
139
+ == "Number of variables in vars does not eqaul the number of variables in the model."
140
+ )
0 commit comments