# Path: phydmslib/constants.py
# N_NT = len(INDEX_TO_NT)
# 
# N_AA = len(INDEX_TO_AA)
# 
# AA_TO_INDEX = {aa: i for (i, aa) in INDEX_TO_AA.items()}
# 
# N_CODON = len(CODON_TO_INDEX)
# 
# CODON_SINGLEMUT = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# CODON_NONSYN = numpy.full((N_CODON, N_CODON), False, dtype='bool')


import random
import unittest
import numpy
import phydmslib.models
from phydmslib.constants import (N_NT, N_AA, AA_TO_INDEX, N_CODON,
                                 CODON_SINGLEMUT, CODON_NONSYN)
    MODEL = phydmslib.models.ExpCM

    def testExpCM_spielmanwr(self):
        """Test the `ExpCM` function `_spielman_wr`."""
        # create models
        random.seed(1)
        numpy.random.seed(1)
        nsites = 10
        g = numpy.random.dirichlet([5] * N_NT)
        prefs = []
        minpref = 0.01
        for _r in range(nsites):
            rprefs = numpy.random.dirichlet([0.5] * N_AA)
            rprefs[rprefs < minpref] = minpref
            rprefs /= rprefs.sum()
            prefs.append(dict(zip(sorted(AA_TO_INDEX.keys()), rprefs)))

        if self.MODEL == phydmslib.models.ExpCM:
            self.model = phydmslib.models.ExpCM(prefs)
        elif self.MODEL == phydmslib.models.ExpCM_empirical_phi:
            self.model = phydmslib.models.ExpCM_empirical_phi(prefs, g)
        else:
            raise ValueError("Invalid MODEL: {0}".format(self.MODEL))

        # test `_spielman_wr` calculation
        wr = []
        for n in range(self.model.nsites):
            numerator = 0
            denominator = 0
            for x in range(N_CODON):

# Path: phydmslib/constants.py
# N_NT = len(INDEX_TO_NT)
# 
# N_AA = len(INDEX_TO_AA)
# 
# AA_TO_INDEX = {aa: i for (i, aa) in INDEX_TO_AA.items()}
# 
# N_CODON = len(CODON_TO_INDEX)
# 
# CODON_SINGLEMUT = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# CODON_NONSYN = numpy.full((N_CODON, N_CODON), False, dtype='bool')


# Path: tests/test_spielmanwr.py
import random
import unittest
import numpy
import phydmslib.models
from phydmslib.constants import (N_NT, N_AA, AA_TO_INDEX, N_CODON,
                                 CODON_SINGLEMUT, CODON_NONSYN)

    MODEL = phydmslib.models.ExpCM

    def testExpCM_spielmanwr(self):
        """Test the `ExpCM` function `_spielman_wr`."""
        # create models
        random.seed(1)
        numpy.random.seed(1)
        nsites = 10
        g = numpy.random.dirichlet([5] * N_NT)
        prefs = []
        minpref = 0.01
        for _r in range(nsites):
            rprefs = numpy.random.dirichlet([0.5] * N_AA)
            rprefs[rprefs < minpref] = minpref
            rprefs /= rprefs.sum()
            prefs.append(dict(zip(sorted(AA_TO_INDEX.keys()), rprefs)))

        if self.MODEL == phydmslib.models.ExpCM:
            self.model = phydmslib.models.ExpCM(prefs)
        elif self.MODEL == phydmslib.models.ExpCM_empirical_phi:
            self.model = phydmslib.models.ExpCM_empirical_phi(prefs, g)
        else:
            raise ValueError("Invalid MODEL: {0}".format(self.MODEL))

        # test `_spielman_wr` calculation
        wr = []
        for n in range(self.model.nsites):
            numerator = 0
            denominator = 0
            for x in range(N_CODON):

                for y in range(N_CODON):