diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 0000000..e7a8549 --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,11 @@ +name: Lint + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: psf/black@stable + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index f85a99f..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: CI -on: - push: - branches: - - main - pull_request: -jobs: - checks: - name: Checks - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Use pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: pip-${{ hashFiles('**/requirements*.txt') }} - restore-keys: | - pip- - - name: Install development tools - run: | - pip install -r requirements.dev.txt - pip install build twine nox - - name: Check formatting - run: nox -s format - - name: Check for lint - run: nox -s lint - - name: Run tests - run: nox -s test - - name: Check distribution build - run: | - python3 -m build - python3 -m twine check dist/* - - # Disabling for now. - # docs: - # name: Build documentation - # runs-on: ubuntu-latest - # steps: - # - name: Checkout - # uses: actions/checkout@v2 - # - name: Setup Python 3.8 - # uses: actions/setup-python@v2 - # with: - # python-version: 3.8 - # - name: Use pip cache - # uses: actions/cache@v2 - # with: - # path: ~/.cache/pip - # key: pip-${{ hashFiles('**/requirements*.txt') }} - # restore-keys: | - # pip- - # - name: Install nox - # run: pip install nox - # - name: Build docs - # run: nox -s build_docs - # - name: Publish to GitHub Pages - # if: github.event_name == 'push' - # run: | - # # Create empty gh-pages branch - # git checkout --orphan gh-pages - - # # Remove files other than docs - # git rm -rf . - # rm -rf .nox - # find . -name __pycache__ | xargs rm -r - - # # Move docs to root - # mv docs/html/* ./ - # rm -r docs - - # # Prevent GitHub from assuming that this is a Jekyll site - # touch .nojekyll - - # git config user.name "${GITHUB_ACTOR}" - # git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" - - # git add . - # git commit --allow-empty -m "Update docs" - - # git push --force origin gh-pages - - # # Restore the original working tree by checking out the - # # commit that triggered the workflow. - # # This restores requirements.txt so that @actions/cache - # # can use it for determining the cache key. - # git checkout ${GITHUB_SHA} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..af0cf96 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,25 @@ +name: Tests + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Install dependencies + run: python -m pip install -r requirements.txt + - name: Run tests + run: python -m pytest -vs diff --git a/lshmm/api.py b/lshmm/api.py index 9e1fd9d..f917ecf 100644 --- a/lshmm/api.py +++ b/lshmm/api.py @@ -1,4 +1,5 @@ """External API definitions.""" + import warnings import numpy as np @@ -194,8 +195,8 @@ def set_emission_probabilities( # DEV: there's a wrinkle here. e = np.zeros((m, 8)) e[:, EQUAL_BOTH_HOM] = (1 - p_mutation) ** 2 - e[:, UNEQUAL_BOTH_HOM] = p_mutation ** 2 - e[:, BOTH_HET] = (1 - p_mutation) ** 2 + p_mutation ** 2 + e[:, UNEQUAL_BOTH_HOM] = p_mutation**2 + e[:, BOTH_HET] = (1 - p_mutation) ** 2 + p_mutation**2 e[:, REF_HOM_OBS_HET] = 2 * p_mutation * (1 - p_mutation) e[:, REF_HET_OBS_HOM] = p_mutation * (1 - p_mutation) e[:, MISSING_INDEX] = 1 @@ -204,7 +205,6 @@ def set_emission_probabilities( def viterbi_hap(n, m, reference_panel, query, emissions, p_recombination): - V, P, log_likelihood = forwards_viterbi_hap_lower_mem_rescaling( n, m, reference_panel, query, emissions, p_recombination ) @@ -214,7 +214,6 @@ def viterbi_hap(n, m, reference_panel, query, emissions, p_recombination): def viterbi_dip(n, m, reference_panel, query, emissions, p_recombination): - V, P, log_likelihood = forwards_viterbi_dip_low_mem( n, m, reference_panel, query, emissions, p_recombination ) @@ -374,7 +373,6 @@ def path_ll( p_mutation=None, scale_mutation_based_on_n_alleles=True, ): - n, m, ploidy = checks( reference_panel, query, diff --git a/lshmm/forward_backward/fb_diploid.py b/lshmm/forward_backward/fb_diploid.py index 53d1b15..50ffe12 100644 --- a/lshmm/forward_backward/fb_diploid.py +++ b/lshmm/forward_backward/fb_diploid.py @@ -1,4 +1,5 @@ """Collection of functions to run forwards and backwards algorithms on haploid genotype data, where the data is structured as variants x samples.""" + import numpy as np from lshmm import jit @@ -12,6 +13,7 @@ MISSING = -1 MISSING_INDEX = 3 + # https://github.com/numba/numba/issues/1269 @jit.numba_njit def np_apply_along_axis(func1d, axis, arr): @@ -51,7 +53,7 @@ def forwards_ls_dip(n, m, G, s, e, r, norm=True): """Matrix based diploid LS forward algorithm using numpy vectorisation.""" # Initialise the forward tensor F = np.zeros((m, n, n)) - F[0, :, :] = 1 / (n ** 2) + F[0, :, :] = 1 / (n**2) c = np.ones(m) r_n = r / n @@ -143,7 +145,6 @@ def backwards_ls_dip(n, m, G, s, e, c, r): # Backwards for l in range(m - 2, -1, -1): - if s[0, l + 1] == MISSING: index = MISSING_INDEX * np.ones( (n, n), dtype=np.int64 @@ -181,7 +182,7 @@ def forward_ls_dip_starting_point(n, m, G, s, e, r): r_n = r / n for j1 in range(n): for j2 in range(n): - F[0, j1, j2] = 1 / (n ** 2) + F[0, j1, j2] = 1 / (n**2) if s[0, 0] == MISSING: index_tmp = MISSING_INDEX else: @@ -193,7 +194,6 @@ def forward_ls_dip_starting_point(n, m, G, s, e, r): F[0, j1, j2] *= e[0, index_tmp] for l in range(1, m): - # Determine the various components F_no_change = np.zeros((n, n)) F_j1_change = np.zeros(n) @@ -266,7 +266,6 @@ def backward_ls_dip_starting_point(n, m, G, s, e, r): r_n = r / n for l in range(m - 2, -1, -1): - # Determine the various components B_no_change = np.zeros((n, n)) B_j1_change = np.zeros(n) @@ -341,7 +340,7 @@ def forward_ls_dip_loop(n, m, G, s, e, r, norm=True): F = np.zeros((m, n, n)) for j1 in range(n): for j2 in range(n): - F[0, j1, j2] = 1 / (n ** 2) + F[0, j1, j2] = 1 / (n**2) if s[0, 0] == MISSING: index_tmp = MISSING_INDEX else: @@ -355,12 +354,10 @@ def forward_ls_dip_loop(n, m, G, s, e, r, norm=True): c = np.ones(m) if norm: - c[0] = np.sum(F[0, :, :]) F[0, :, :] *= 1 / c[0] for l in range(1, m): - # Determine the various components F_no_change = np.zeros((n, n)) F_j_change = np.zeros(n) @@ -406,9 +403,7 @@ def forward_ls_dip_loop(n, m, G, s, e, r, norm=True): ll = np.sum(np.log10(c)) else: - for l in range(1, m): - # Determine the various components F_no_change = np.zeros((n, n)) F_j1_change = np.zeros(n) @@ -466,7 +461,6 @@ def backward_ls_dip_loop(n, m, G, s, e, c, r): r_n = r / n for l in range(m - 2, -1, -1): - # Determine the various components B_no_change = np.zeros((n, n)) B_j1_change = np.zeros(n) diff --git a/lshmm/forward_backward/fb_haploid.py b/lshmm/forward_backward/fb_haploid.py index d0f03df..69d01fc 100644 --- a/lshmm/forward_backward/fb_haploid.py +++ b/lshmm/forward_backward/fb_haploid.py @@ -1,4 +1,5 @@ """Collection of functions to run forwards and backwards algorithms on haploid genotype data, where the data is structured as variants x samples.""" + import numpy as np from lshmm import jit @@ -14,7 +15,6 @@ def forwards_ls_hap(n, m, H, s, e, r, norm=True): r_n = r / n if norm: - c = np.zeros(m) for i in range(n): F[0, i] = ( @@ -40,7 +40,6 @@ def forwards_ls_hap(n, m, H, s, e, r, norm=True): ll = np.sum(np.log10(c)) else: - c = np.ones(m) for i in range(n): diff --git a/lshmm/vit_diploid.py b/lshmm/vit_diploid.py index f140861..316b5d0 100644 --- a/lshmm/vit_diploid.py +++ b/lshmm/vit_diploid.py @@ -1,4 +1,5 @@ """Collection of functions to run Viterbi algorithms on dipoid genotype data, where the data is structured as variants x samples.""" + import numpy as np from . import jit @@ -6,6 +7,7 @@ MISSING = -1 MISSING_INDEX = 3 + # https://github.com/numba/numba/issues/1269 @jit.numba_njit def np_apply_along_axis(func1d, axis, arr): @@ -60,7 +62,7 @@ def forwards_viterbi_dip_naive(n, m, G, s, e, r): + 2 * np.int64((G[0, j1, j2] == 1)) + np.int64(s[0, 0] == 1) ) - V[0, j1, j2] = 1 / (n ** 2) * e[0, index_tmp] + V[0, j1, j2] = 1 / (n**2) * e[0, index_tmp] for l in range(1, m): if s[0, l] == MISSING: @@ -117,7 +119,7 @@ def forwards_viterbi_dip_naive_low_mem(n, m, G, s, e, r): + 2 * np.int64((G[0, j1, j2] == 1)) + np.int64(s[0, 0] == 1) ) - V_previous[j1, j2] = 1 / (n ** 2) * e[0, index_tmp] + V_previous[j1, j2] = 1 / (n**2) * e[0, index_tmp] # Take a look at Haploid Viterbi implementation in Jeromes code and see if we can pinch some ideas. # Diploid Viterbi, with smaller memory footprint. @@ -175,7 +177,7 @@ def forwards_viterbi_dip_low_mem(n, m, G, s, e, r): + 2 * np.int64((G[0, j1, j2] == 1)) + np.int64(s[0, 0] == 1) ) - V_previous[j1, j2] = 1 / (n ** 2) * e[0, index_tmp] + V_previous[j1, j2] = 1 / (n**2) * e[0, index_tmp] # Diploid Viterbi, with smaller memory footprint, rescaling, and using the structure of the HMM. for l in range(1, m): @@ -203,7 +205,6 @@ def forwards_viterbi_dip_low_mem(n, m, G, s, e, r): for j1 in range(n): for j2 in range(n): - V_single_switch = max(V_rowcol_max[j1], V_rowcol_max[j2]) P_single_switch = np.argmax( np.array([V_rowcol_max[j1], V_rowcol_max[j2]]) @@ -269,7 +270,7 @@ def forwards_viterbi_dip_low_mem_no_pointer(n, m, G, s, e, r): + 2 * np.int64((G[0, j1, j2] == 1)) + np.int64(s[0, 0] == 1) ) - V_previous[j1, j2] = 1 / (n ** 2) * e[0, index_tmp] + V_previous[j1, j2] = 1 / (n**2) * e[0, index_tmp] # Diploid Viterbi, with smaller memory footprint, rescaling, and using the structure of the HMM. for l in range(1, m): @@ -300,7 +301,6 @@ def forwards_viterbi_dip_low_mem_no_pointer(n, m, G, s, e, r): for j1 in range(n): for j2 in range(n): - V_single_switch = max(V_rowcol_max[j1], V_rowcol_max[j2]) V[j1, j2] = V_previous[j1, j2] * no_switch # No switch in either @@ -356,7 +356,7 @@ def forwards_viterbi_dip_naive_vec(n, m, G, s, e, r): + 2 * np.int64((G[0, j1, j2] == 1)) + np.int64(s[0, 0] == 1) ) - V[0, j1, j2] = 1 / (n ** 2) * e[0, index_tmp] + V[0, j1, j2] = 1 / (n**2) * e[0, index_tmp] # Jumped the gun - vectorising. for l in range(1, m): @@ -406,7 +406,7 @@ def forwards_viterbi_dip_naive_full_vec(n, m, G, s, e, r): + 2 * (G[0, :, :] == 1).astype(np.int64) + np.int64(s[0, 0] == 1) ) - V[0, :, :] = 1 / (n ** 2) * e[0, index] + V[0, :, :] = 1 / (n**2) * e[0, index] r_n = r / n for l in range(1, m): @@ -511,12 +511,11 @@ def path_ll_dip(n, m, G, phased_path, s, e, r): + 2 * np.int64(G[0, phased_path[0][0], phased_path[1][0]] == 1) + np.int64(s[0, 0] == 1) ) - log_prob_path = np.log10(1 / (n ** 2) * e[0, index]) + log_prob_path = np.log10(1 / (n**2) * e[0, index]) old_phase = np.array([phased_path[0][0], phased_path[1][0]]) r_n = r / n for l in range(1, m): - if s[0, l] == MISSING: index = MISSING_INDEX else: diff --git a/lshmm/vit_haploid.py b/lshmm/vit_haploid.py index 22aa7d3..7fec45e 100644 --- a/lshmm/vit_haploid.py +++ b/lshmm/vit_haploid.py @@ -1,4 +1,5 @@ """Collection of functions to run Viterbi algorithms on haploid genotype data, where the data is structured as variants x samples.""" + import numpy as np from . import jit diff --git a/noxfile.py b/noxfile.py deleted file mode 100644 index f12b369..0000000 --- a/noxfile.py +++ /dev/null @@ -1,57 +0,0 @@ -import nox - - -@nox.session -def format(session): - session.install("-r", "requirements.dev.txt") - - session.run("black", ".") - session.run("isort", ".") - - -@nox.session -def lint(session): - session.install("-r", "requirements.dev.txt") - session.install(".") - - session.run("pylint", "lshmm") - # Removing for now - need to improve the test code - # session.run("pylint", "tests") - - -@nox.session -def test(session): - session.install("-r", "requirements.dev.txt") - session.install(".") - - session.run("pytest") - - -# Disabling until we have some documentation -@nox.session -def build_docs(session): - session.install("-r", "docs/requirements.docs.txt") - session.install(".") - - session.cd("docs") - session.run("rm", "-rf", "api_reference", external=True) - session.run("python3", "generate_api_reference.py") - - session.run("rm", "-rf", "html", external=True) - session.run("python3", "-m", "sphinx", "-W", "-b", "html", ".", "html") - - -@nox.session -def serve_docs(session): - session.cd("docs/html") - session.run("python3", "-m", "http.server") - - -@nox.session -def pip_compile(session): - session.install("pip-tools") - - session.run("pip-compile", *session.posargs) - - -nox.options.sessions = ["format", "lint", "test"] diff --git a/requirements.dev.in b/requirements.dev.in deleted file mode 100644 index 2ae764b..0000000 --- a/requirements.dev.in +++ /dev/null @@ -1,6 +0,0 @@ -black==21.9b0 # This should be kept in sync with the version in .pre-commit-config.yaml -isort==5.9.3 # This should be kept in sync with the version in .pre-commit-config.yaml -pylint -pytest -msprime -tskit diff --git a/requirements.dev.txt b/requirements.dev.txt deleted file mode 100644 index aedf1e7..0000000 --- a/requirements.dev.txt +++ /dev/null @@ -1,93 +0,0 @@ -# -# This file is autogenerated by pip-compile with python 3.8 -# To update, run: -# -# pip-compile requirements.dev.in -# -astroid==2.9.3 - # via pylint -attrs==21.4.0 - # via - # demes - # jsonschema - # pytest -black==21.9b0 - # via -r requirements.dev.in -click==8.0.4 - # via black -demes==0.2.1 - # via msprime -importlib-resources==5.4.0 - # via jsonschema -iniconfig==1.1.1 - # via pytest -isort==5.9.3 - # via - # -r requirements.dev.in - # pylint -jsonschema==4.4.0 - # via tskit -lazy-object-proxy==1.7.1 - # via astroid -mccabe==0.6.1 - # via pylint -msprime==1.1.1 - # via -r requirements.dev.in -mypy-extensions==0.4.3 - # via black -newick==1.3.2 - # via msprime -numpy==1.22.2 - # via - # msprime - # tskit -packaging==21.3 - # via pytest -pathspec==0.9.0 - # via black -platformdirs==2.5.1 - # via - # black - # pylint -pluggy==1.0.0 - # via pytest -py==1.11.0 - # via pytest -pylint==2.12.2 - # via -r requirements.dev.in -pyparsing==3.0.7 - # via packaging -pyrsistent==0.18.1 - # via jsonschema -pytest==7.0.1 - # via -r requirements.dev.in -regex==2022.1.18 - # via black -ruamel-yaml==0.17.21 - # via demes -ruamel-yaml-clib==0.2.6 - # via ruamel-yaml -svgwrite==1.4.1 - # via tskit -toml==0.10.2 - # via pylint -tomli==1.2.3 - # via - # black - # pytest -tskit==0.4.1 - # via - # -r requirements.dev.in - # msprime -typing-extensions==4.1.1 - # via - # astroid - # black - # pylint -wrapt==1.13.3 - # via astroid -zipp==3.7.0 - # via importlib-resources - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..553f70f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +black +pytest +msprime +tskit +numba diff --git a/setup.py b/setup.py index 04697a0..9329697 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup + setup( use_scm_version=True, - setup_requires=['setuptools_scm'], - + setup_requires=["setuptools_scm"], ) diff --git a/tests/test_API.py b/tests/test_API.py index 6c0678c..129e67a 100644 --- a/tests/test_API.py +++ b/tests/test_API.py @@ -27,7 +27,6 @@ class LSBase: """Superclass of Li and Stephens tests.""" def example_haplotypes(self, ts, seed=42): - H = ts.genotype_matrix() s = H[:, 0].reshape(1, H.shape[0]) H = H[:, 1:] @@ -70,8 +69,8 @@ def genotype_emission(self, mu, m): # Define the emission probability matrix e = np.zeros((m, 8)) e[:, EQUAL_BOTH_HOM] = (1 - mu) ** 2 - e[:, UNEQUAL_BOTH_HOM] = mu ** 2 - e[:, BOTH_HET] = (1 - mu) ** 2 + mu ** 2 + e[:, UNEQUAL_BOTH_HOM] = mu**2 + e[:, BOTH_HET] = (1 - mu) ** 2 + mu**2 e[:, REF_HOM_OBS_HET] = 2 * mu * (1 - mu) e[:, REF_HET_OBS_HOM] = mu * (1 - mu) e[:, MISSING_INDEX] = 1 @@ -262,7 +261,6 @@ class TestMethodsDip(FBAlgorithmBase): def verify(self, ts): for n, m, G_vs, s, e_vs, r, mu in self.example_parameters_genotypes(ts): - F_vs, c_vs, ll_vs = fbd.forward_ls_dip_loop( n, m, G_vs, s, e_vs, r, norm=True ) @@ -283,7 +281,6 @@ class TestViterbiHap(VitAlgorithmBase): def verify(self, ts): for n, m, H_vs, s, e_vs, r, mu in self.example_parameters_haplotypes(ts): - V_vs, P_vs, ll_vs = vh.forwards_viterbi_hap_lower_mem_rescaling( n, m, H_vs, s, e_vs, r ) @@ -299,7 +296,6 @@ class TestViterbiDip(VitAlgorithmBase): def verify(self, ts): for n, m, G_vs, s, e_vs, r, mu in self.example_parameters_genotypes(ts): - V_vs, P_vs, ll_vs = vd.forwards_viterbi_dip_low_mem(n, m, G_vs, s, e_vs, r) path_vs = vd.backwards_viterbi_dip(m, V_vs, P_vs) phased_path_vs = vd.get_phased_path(n, path_vs) diff --git a/tests/test_API_multiallelic.py b/tests/test_API_multiallelic.py index 338f117..92f1ab3 100644 --- a/tests/test_API_multiallelic.py +++ b/tests/test_API_multiallelic.py @@ -27,7 +27,6 @@ class LSBase: """Superclass of Li and Stephens tests.""" def example_haplotypes(self, ts, num_random=10, seed=42): - H = ts.genotype_matrix() s = H[:, 0].reshape(1, H.shape[0]) H = H[:, 1:] @@ -216,7 +215,6 @@ class TestViterbiHap(VitAlgorithmBase): def verify(self, ts): for n, m, H_vs, s, e_vs, r, mu in self.example_parameters_haplotypes(ts): - V_vs, P_vs, ll_vs = vh.forwards_viterbi_hap_lower_mem_rescaling( n, m, H_vs, s, e_vs, r ) diff --git a/tests/test_LS_haploid_diploid.py b/tests/test_LS_haploid_diploid.py index 5b4dc48..9b9f7d8 100644 --- a/tests/test_LS_haploid_diploid.py +++ b/tests/test_LS_haploid_diploid.py @@ -28,7 +28,6 @@ class LSBase: """Superclass of Li and Stephens tests.""" def example_haplotypes(self, ts): - H = ts.genotype_matrix() s = H[:, 0].reshape(1, H.shape[0]) H = H[:, 1:] @@ -58,7 +57,7 @@ def genotype_emission(self, mu, m): # Define the emission probability matrix e = np.zeros((m, 8)) e[:, EQUAL_BOTH_HOM] = (1 - mu) ** 2 - e[:, UNEQUAL_BOTH_HOM] = mu ** 2 + e[:, UNEQUAL_BOTH_HOM] = mu**2 e[:, BOTH_HET] = 1 - mu e[:, REF_HOM_OBS_HET] = 2 * mu * (1 - mu) e[:, REF_HET_OBS_HOM] = mu * (1 - mu) @@ -97,7 +96,6 @@ def example_parameters_haplotypes(self, ts, seed=42): def example_parameters_haplotypes_larger( self, ts, seed=42, mean_r=1e-5, mean_mu=1e-5 ): - np.random.seed(seed) H, haplotypes = self.example_haplotypes(ts) n = H.shape[1] @@ -116,7 +114,6 @@ def example_parameters_haplotypes_larger( yield n, m, H, s, e, r def example_genotypes(self, ts, seed=42): - H = ts.genotype_matrix() s = H[:, 0].reshape(1, H.shape[0]) + H[:, 1].reshape(1, H.shape[0]) H = H[:, 2:] @@ -288,7 +285,6 @@ class TestNonTreeMethodsDip(FBAlgorithmBase): def verify(self, ts): for n, m, G_vs, s, e_vs, r in self.example_parameters_genotypes(ts): - F_vs, c_vs, ll_vs = fbd.forwards_ls_dip(n, m, G_vs, s, e_vs, r, norm=True) B_vs = fbd.backwards_ls_dip(n, m, G_vs, s, e_vs, c_vs, r) self.assertAllClose(np.sum(F_vs * B_vs, (1, 2)), np.ones(m)) @@ -329,7 +325,6 @@ def verify(self, ts): def verify_larger(self, ts): for n, m, G_vs, s, e_vs, r in self.example_parameters_genotypes_larger(ts): - F_vs, c_vs, ll_vs = fbd.forwards_ls_dip(n, m, G_vs, s, e_vs, r, norm=True) B_vs = fbd.backwards_ls_dip(n, m, G_vs, s, e_vs, c_vs, r) self.assertAllClose(np.sum(F_vs * B_vs, (1, 2)), np.ones(m)) @@ -377,7 +372,6 @@ class TestNonTreeViterbiHap(VitAlgorithmBase): def verify(self, ts): for n, m, H_vs, s, e_vs, r in self.example_parameters_haplotypes(ts): - V_vs, P_vs, ll_vs = vh.forwards_viterbi_hap_naive(n, m, H_vs, s, e_vs, r) path_vs = vh.backwards_viterbi_hap(m, V_vs[m - 1, :], P_vs) ll_check = vh.path_ll_hap(n, m, H_vs, path_vs, s, e_vs, r) @@ -437,7 +431,6 @@ def verify(self, ts): def verify_larger(self, ts): for n, m, H_vs, s, e_vs, r in self.example_parameters_haplotypes_larger(ts): - V_vs, P_vs, ll_vs = vh.forwards_viterbi_hap_naive(n, m, H_vs, s, e_vs, r) path_vs = vh.backwards_viterbi_hap(m, V_vs[m - 1, :], P_vs) ll_check = vh.path_ll_hap(n, m, H_vs, path_vs, s, e_vs, r) @@ -499,7 +492,6 @@ class TestNonTreeViterbiDip(VitAlgorithmBase): def verify(self, ts): for n, m, G_vs, s, e_vs, r in self.example_parameters_genotypes(ts): - V_vs, P_vs, ll_vs = vd.forwards_viterbi_dip_naive(n, m, G_vs, s, e_vs, r) path_vs = vd.backwards_viterbi_dip(m, V_vs[m - 1, :, :], P_vs) phased_path_vs = vd.get_phased_path(n, path_vs) @@ -558,7 +550,6 @@ def verify(self, ts): def verify_larger(self, ts): for n, m, G_vs, s, e_vs, r in self.example_parameters_genotypes_larger(ts): - V_vs, P_vs, ll_vs = vd.forwards_viterbi_dip_naive(n, m, G_vs, s, e_vs, r) path_vs = vd.backwards_viterbi_dip(m, V_vs[m - 1, :, :], P_vs) phased_path_vs = vd.get_phased_path(n, path_vs)