# Path: phydmslib/constants.py
# CODON_TO_AA = []
# 
# N_CODON = len(CODON_TO_INDEX)
# 
# 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 copy
import numpy
import scipy.optimize
import sympy
import phydmslib.models
from phydmslib.constants import CODON_TO_AA, N_CODON, N_AA, AA_TO_INDEX, N_NT
                                                          ), (-expcm_fitprefs
                                                    .tildeFrxy[r][x][y]) /
                                                    values[pirAx]))))
                            self.assertTrue(numpy.allclose(
                                    float(dFrxy_dpirAy_equal
                                          .subs(values.items())),
                                    expcm_fitprefs.tildeFrxy[r][x][y] /
                                    values[pirAy]))
                    else:
                        self.assertTrue(numpy.allclose(
                                float(dFrxy_dpirAx.subs(values.items())),
                                -expcm_fitprefs.tildeFrxy[r][x][y] /
                                values[pirAx]))
                        self.assertTrue(numpy.allclose(
                                float(dFrxy_dpirAy.subs(values.items())),
                                expcm_fitprefs.tildeFrxy[r][x][y] /
                                values[pirAy]))

    def setUp(self):
        """Set up for tests."""
        numpy.random.seed(1)
        random.seed(1)
        nsites = 1
        minpref = 0.001
        self.prefs = []
        for _r in range(nsites):
            rprefs = numpy.random.dirichlet([0.7] * N_AA)
            rprefs[rprefs < minpref] = minpref
            rprefs[0] = rprefs[1] + 1.0e-8  # near equal prefs handled OK
            rprefs /= rprefs.sum()

# Path: phydmslib/constants.py
# CODON_TO_AA = []
# 
# N_CODON = len(CODON_TO_INDEX)
# 
# 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_expcm_fitprefs.py
import random
import unittest
import copy
import numpy
import scipy.optimize
import sympy
import phydmslib.models
from phydmslib.constants import CODON_TO_AA, N_CODON, N_AA, AA_TO_INDEX, N_NT

                                                          ), (-expcm_fitprefs
                                                    .tildeFrxy[r][x][y]) /
                                                    values[pirAx]))))
                            self.assertTrue(numpy.allclose(
                                    float(dFrxy_dpirAy_equal
                                          .subs(values.items())),
                                    expcm_fitprefs.tildeFrxy[r][x][y] /
                                    values[pirAy]))
                    else:
                        self.assertTrue(numpy.allclose(
                                float(dFrxy_dpirAx.subs(values.items())),
                                -expcm_fitprefs.tildeFrxy[r][x][y] /
                                values[pirAx]))
                        self.assertTrue(numpy.allclose(
                                float(dFrxy_dpirAy.subs(values.items())),
                                expcm_fitprefs.tildeFrxy[r][x][y] /
                                values[pirAy]))

    def setUp(self):
        """Set up for tests."""
        numpy.random.seed(1)
        random.seed(1)
        nsites = 1
        minpref = 0.001
        self.prefs = []
        for _r in range(nsites):
            rprefs = numpy.random.dirichlet([0.7] * N_AA)
            rprefs[rprefs < minpref] = minpref
            rprefs[0] = rprefs[1] + 1.0e-8  # near equal prefs handled OK
            rprefs /= rprefs.sum()

            self.prefs.append(dict(zip(sorted(AA_TO_INDEX.keys()), rprefs)))