Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Apr 20, 2024
1 parent 3515d60 commit fad14f3
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions tests/test_API_multiallelic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
class TestMethodsHaploid(lsbase.FBAlgorithmBase):
def test_multiallelic_n10_no_recombination(self):
ts = self.get_multiallelic_n10_no_recombination()
return ts
self.verify(ts)

def test_multiallelic_n6(self):
ts = self.get_multiallelic_n6()
return ts
self.verify(ts)

def test_multiallelic_n8(self):
ts = self.get_multiallelic_n8()
return ts
self.verify(ts)

def test_multiallelic_n16(self):
ts = self.get_multiallelic_n16()
return ts
self.verify(ts)

def verify(self, ts):
for n, m, H_vs, s, e_vs, r, mu in self.get_examples_parameters_haploid(ts):
for n, m, H_vs, s, e_vs, r, mu in self.get_examples_pars_haploid(ts):
F_vs, c_vs, ll_vs = fbh.forwards_ls_hap(n, m, H_vs, s, e_vs, r)
B_vs = fbh.backwards_ls_hap(n, m, H_vs, s, e_vs, c_vs, r)
F, c, ll = ls.forwards(H_vs, s, r, p_mutation=mu)
Expand All @@ -33,7 +33,7 @@ def verify(self, ts):
self.assertAllClose(B, B_vs)
self.assertAllClose(ll_vs, ll)

for n, m, H_vs, s, e_vs, r, mu in self.get_examples_parameters_haploid(
for n, m, H_vs, s, e_vs, r, mu in self.get_examples_pars_haploid(
ts, scale_mutation=False
):
F_vs, c_vs, ll_vs = fbh.forwards_ls_hap(n, m, H_vs, s, e_vs, r)
Expand All @@ -52,29 +52,28 @@ def verify(self, ts):
class TestViterbiHaploid(lsbase.ViterbiAlgorithmBase):
def test_multiallelic_n10_no_recombination(self):
ts = self.get_multiallelic_n10_no_recombination()
return ts
self.verify(ts)

def test_multiallelic_n6(self):
ts = self.get_multiallelic_n6()
return ts
self.verify(ts)

def test_multiallelic_n8(self):
ts = self.get_multiallelic_n8()
return ts
self.verify(ts)

def test_multiallelic_n16(self):
ts = self.get_multiallelic_n16()
return ts
self.verify(ts)

def verify(self, ts):
for n, m, H_vs, s, e_vs, r, mu in self.get_examples_parameters_haploid(ts):
for n, m, H_vs, s, e_vs, r, mu in self.get_examples_pars_haploid(ts):
V_vs, P_vs, ll_vs = vh.forwards_viterbi_hap_lower_mem_rescaling(
n, m, H_vs, s, e_vs, r
)
path_vs = vh.backwards_viterbi_hap(m, V_vs, P_vs)
path_ll_hap = vh.path_ll_hap(n, m, H_vs, path_vs, s, e_vs, r)
path, ll = ls.viterbi(H_vs, s, r, p_mutation=mu)

self.assertAllClose(ll_vs, ll)
self.assertAllClose(ll_vs, path_ll_hap)
self.assertAllClose(path_vs, path)

0 comments on commit fad14f3

Please sign in to comment.