# Path: phydmslib/constants.py
# N_CODON = len(CODON_TO_INDEX)
# 
# N_NT = len(INDEX_TO_NT)
# 
# AA_TO_INDEX = {aa: i for (i, aa) in INDEX_TO_AA.items()}
# 
# N_AA = len(INDEX_TO_AA)
# 
# CODON_NT_COUNT = numpy.zeros((N_NT, N_CODON), dtype='int')


import random
import unittest
import scipy.linalg
import scipy.optimize
import numpy
import phydmslib.models
from phydmslib.constants import (N_CODON, N_NT, AA_TO_INDEX, N_AA,
                                 CODON_NT_COUNT)

            self.check_ExpCM_attributes()

            self.check_ExpCM_derivatives()

            self.check_ExpCM_matrix_exponentials()

    def check_empirical_phi(self):
        """Check that `phi` gives right `g`, and has right derivative."""
        nt_freqs = [0] * N_NT
        for r in range(self.nsites):
            for x in range(N_CODON):
                for w in range(N_NT):
                    nt_freqs[w] += self.model.prx[r][x] * CODON_NT_COUNT[w][x]
        self.assertTrue(numpy.allclose(sum(nt_freqs), 3 * self.nsites))
        nt_freqs = numpy.array(nt_freqs)
        nt_freqs /= nt_freqs.sum()
        self.assertTrue(
            numpy.allclose(nt_freqs, self.model.g, atol=1e-5),
            "Actual nt_freqs: {0}\nExpected (g): {1}"
            .format(nt_freqs, self.model.g))

        def func_phi(beta, expcm, w):
            expcm.updateParams({"beta": beta[0]})
            return expcm.phi[w]

        def func_dphi(beta, expcm, w):
            expcm.updateParams({"beta": beta[0]})
            return expcm.dphi_dbeta[w]


# Path: phydmslib/constants.py
# N_CODON = len(CODON_TO_INDEX)
# 
# N_NT = len(INDEX_TO_NT)
# 
# AA_TO_INDEX = {aa: i for (i, aa) in INDEX_TO_AA.items()}
# 
# N_AA = len(INDEX_TO_AA)
# 
# CODON_NT_COUNT = numpy.zeros((N_NT, N_CODON), dtype='int')


# Path: tests/test_expcm_divpressure.py
import random
import unittest
import scipy.linalg
import scipy.optimize
import numpy
import phydmslib.models
from phydmslib.constants import (N_CODON, N_NT, AA_TO_INDEX, N_AA,
                                 CODON_NT_COUNT)


            self.check_ExpCM_attributes()

            self.check_ExpCM_derivatives()

            self.check_ExpCM_matrix_exponentials()

    def check_empirical_phi(self):
        """Check that `phi` gives right `g`, and has right derivative."""
        nt_freqs = [0] * N_NT
        for r in range(self.nsites):
            for x in range(N_CODON):
                for w in range(N_NT):
                    nt_freqs[w] += self.model.prx[r][x] * CODON_NT_COUNT[w][x]
        self.assertTrue(numpy.allclose(sum(nt_freqs), 3 * self.nsites))
        nt_freqs = numpy.array(nt_freqs)
        nt_freqs /= nt_freqs.sum()
        self.assertTrue(
            numpy.allclose(nt_freqs, self.model.g, atol=1e-5),
            "Actual nt_freqs: {0}\nExpected (g): {1}"
            .format(nt_freqs, self.model.g))

        def func_phi(beta, expcm, w):
            expcm.updateParams({"beta": beta[0]})
            return expcm.phi[w]

        def func_dphi(beta, expcm, w):
            expcm.updateParams({"beta": beta[0]})
            return expcm.dphi_dbeta[w]


        for w in range(N_NT):