Skip to content

Commit 3526b62

Browse files
committed
More comments
1 parent 98cc77e commit 3526b62

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

tests/test_approximations.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def pdf(t_i, t_j, a_i, b_i, a_j, b_j, y, mu):
7070
)
7171

7272
def test_sufficient_statistics(self, pars):
73-
print((pars[5] - pars[3]) / (pars[1] + pars[5]))
7473
logconst, t_i, ln_t_i, t_j, ln_t_j = approx.sufficient_statistics(*pars)
7574
ck_normconst = scipy.integrate.dblquad(
7675
lambda ti, tj: self.pdf(ti, tj, *pars), 0, np.inf, lambda tj: tj, np.inf
@@ -184,5 +183,4 @@ def test_approximate_gamma(self, k):
184183
lambda x: conditional_coalescent_pdf(x, self.n, k),
185184
lambda x: scipy.stats.gamma.logpdf(x, alpha_1, scale=1 / beta_1),
186185
)
187-
print(kl_1, kl_0)
188186
assert kl_1 < kl_0

tests/test_hypergeo.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,13 @@ def test_2f1(self, pars):
9090
f, s, *_ = hypergeo._hyp2f1_taylor_series(*pars)
9191
check = self._2f1_validate(*pars)
9292
assert s == mpmath.sign(check)
93-
print(f, mpmath.log(mpmath.fabs(check)))
9493
assert np.isclose(f, float(mpmath.log(mpmath.fabs(check))))
9594

9695
def test_2f1_grad(self, pars):
9796
_, _, *grad = hypergeo._hyp2f1_taylor_series(*pars)
9897
grad = grad[:-1]
9998
offset = self._2f1_validate(*pars)
10099
check = self._2f1_grad_validate(*pars, offset=offset)
101-
print(grad, check)
102100
assert np.allclose(grad, check)
103101

104102

@@ -142,7 +140,6 @@ def test_2f1(self, pars):
142140
f, s, *_ = hypergeo._hyp2f1_recurrence(*pars)
143141
check = self._2f1_validate(*pars)
144142
assert s == mpmath.sign(check)
145-
print(f, mpmath.log(mpmath.fabs(check)))
146143
assert np.isclose(f, float(mpmath.log(mpmath.fabs(check))))
147144

148145
def test_2f1_grad(self, pars):
@@ -152,7 +149,6 @@ def test_2f1_grad(self, pars):
152149
offset = self._2f1_validate(*pars)
153150
check = self._2f1_grad_validate(*pars, offset=offset)
154151
check[1] = 0.0 # integer parameter has no gradient
155-
print(grad, check)
156152
assert np.allclose(grad, check)
157153

158154

@@ -235,7 +231,6 @@ def test_2f1(self, muts, hyp2f1_func, pars):
235231
f, s, *_ = hyp2f1_func(*pars)
236232
assert s > 0
237233
check = float(mpmath.log(self._2f1_validate(*pars)))
238-
print(f, check)
239234
assert np.isclose(f, check)
240235

241236
def test_2f1_grad(self, muts, hyp2f1_func, pars):
@@ -244,5 +239,4 @@ def test_2f1_grad(self, muts, hyp2f1_func, pars):
244239
assert s > 0
245240
offset = self._2f1_validate(*pars)
246241
check = self._2f1_grad_validate(*pars, offset=offset)
247-
print(grad, check)
248242
assert np.allclose(grad, check)

tsdate/core.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,10 +1000,11 @@ def propagate(self, *, edges, progress=None):
10001000
continue
10011001
if edge.parent in self.fixednodes:
10021002
raise ValueError("Internal nodes can not be fixed in EP algorithm")
1003+
# Get the edge likelihood (Poisson) in terms of a gamma distribution
10031004
edge_lik = self.lik.to_gamma(edge, natural=True)
10041005
# Get the cavity posteriors: that is, the rest of the approximation
1005-
# without the factor for this edge. This only involves the variational
1006-
# parameters for the parent and child on the edge.
1006+
# without the factor for this edge. This only involves updating the
1007+
# variational parameters for the parent and child on the edge.
10071008
parent_cavity = self.lik.ratio(
10081009
self.posterior[edge.parent], self.parent_message[edge.id]
10091010
)
@@ -1019,14 +1020,16 @@ def propagate(self, *, edges, progress=None):
10191020
self.posterior[edge.child],
10201021
) = approx.gamma_projection(*parent_cavity, *child_cavity, *edge_lik)
10211022
# Get the messages: that is, the multiplicative difference between
1022-
# the target and cavity posteriors.
1023+
# the target and cavity posteriors. This only involves updating the
1024+
# variational parameters for the parent and child on the edge.
10231025
self.parent_message[edge.id] = self.lik.ratio(
10241026
self.posterior[edge.parent], parent_cavity
10251027
)
10261028
self.child_message[edge.id] = self.lik.ratio(
10271029
self.posterior[edge.child], child_cavity
10281030
)
1029-
# Get the approximation to the marginal likelihood
1031+
# Get the contribution to the (approximate) marginal likelihood from
1032+
# the edge.
10301033
# TODO not complete
10311034
self.factor_norm[edge.id] = norm_const
10321035

0 commit comments

Comments
 (0)