# Path: phydmslib/constants.py
# N_AA = len(INDEX_TO_AA)
# 
# AA_TO_INDEX = {aa: i for (i, aa) in INDEX_TO_AA.items()}
# 
# N_NT = len(INDEX_TO_NT)


import random
import unittest
import numpy
import scipy.optimize
import phydmslib.models
from phydmslib.constants import N_AA, AA_TO_INDEX, N_NT
    # use approach here to run multiple tests:
    # http://stackoverflow.com/questions/17260469/instantiate-python-unittest-testcase-with-arguments
    BASEMODEL = phydmslib.models.ExpCM

    def test_GammaDistributedOmega(self):
        """Initialize, test values, update, test again."""
        random.seed(1)
        numpy.random.seed(1)
        nsites = 10

        if self.BASEMODEL == phydmslib.models.ExpCM:
            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)))
            paramvalues = {"eta": numpy.random.dirichlet([5] * (N_NT - 1)),
                           "omega": 0.7,
                           "kappa": 2.5,
                           "beta": 1.2,
                           "mu": 0.5}
            basemodel = self.BASEMODEL(prefs)
            assert set(paramvalues.keys()) == set(
                basemodel.freeparams
            ), "{0} vs {1}".format(set(paramvalues.keys()),
                                   set(basemodel.freeparams))
            basemodel.updateParams(paramvalues)
        elif self.BASEMODEL == phydmslib.models.YNGKP_M0:

# Path: phydmslib/constants.py
# N_AA = len(INDEX_TO_AA)
# 
# AA_TO_INDEX = {aa: i for (i, aa) in INDEX_TO_AA.items()}
# 
# N_NT = len(INDEX_TO_NT)


# Path: tests/test_gammadistributedomega_model.py
import random
import unittest
import numpy
import scipy.optimize
import phydmslib.models
from phydmslib.constants import N_AA, AA_TO_INDEX, N_NT

    # use approach here to run multiple tests:
    # http://stackoverflow.com/questions/17260469/instantiate-python-unittest-testcase-with-arguments
    BASEMODEL = phydmslib.models.ExpCM

    def test_GammaDistributedOmega(self):
        """Initialize, test values, update, test again."""
        random.seed(1)
        numpy.random.seed(1)
        nsites = 10

        if self.BASEMODEL == phydmslib.models.ExpCM:
            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)))
            paramvalues = {"eta": numpy.random.dirichlet([5] * (N_NT - 1)),
                           "omega": 0.7,
                           "kappa": 2.5,
                           "beta": 1.2,
                           "mu": 0.5}
            basemodel = self.BASEMODEL(prefs)
            assert set(paramvalues.keys()) == set(
                basemodel.freeparams
            ), "{0} vs {1}".format(set(paramvalues.keys()),
                                   set(basemodel.freeparams))
            basemodel.updateParams(paramvalues)
        elif self.BASEMODEL == phydmslib.models.YNGKP_M0:

            e_pw = numpy.random.uniform(0.4, 0.6, size=(3, N_NT))