# 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)


import os
import unittest
import random
import numpy
import scipy.optimize
import Bio.Phylo
import phydmslib.models
import phydmslib.treelikelihood
import phydmslib.simulate
import pyvolve
from phydmslib.constants import N_CODON, N_NT, AA_TO_INDEX, N_AA
        tl = (phydmslib.treelikelihood
              .TreeLikelihood(self.tree,
                              self.alignment,
                              self.model,
                              underflowfreq=self.underflowfreq,
                              dparamscurrent=False,
                              dtcurrent=True))
        self.assertEqual(tl.dloglik_dt.shape, tl.t.shape)

    def test_dM_dt(self):
        """Tests model `dM` with respect to `t`."""
        numpy.random.seed(1)
        random.seed(1)
        tl = (phydmslib.treelikelihood
              .TreeLikelihood(self.tree,
                              self.alignment,
                              self.model,
                              underflowfreq=self.underflowfreq,
                              dparamscurrent=False,
                              dtcurrent=True))

        def func(t, k, r, x, y):
            return tl._M(k, t[0], None)[r][x][y]

        def dfunc(t, k, r, x, y):
            return tl._dM(k, t[0], 't', None)[r][x][y]

        for r in range(self.nsites):
            k = random.choice(tl._catindices)
            x = random.randint(0, N_CODON - 1)

# 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)


# Path: tests/test_brlenderivatives.py
import os
import unittest
import random
import numpy
import scipy.optimize
import Bio.Phylo
import phydmslib.models
import phydmslib.treelikelihood
import phydmslib.simulate
import pyvolve
from phydmslib.constants import N_CODON, N_NT, AA_TO_INDEX, N_AA

        tl = (phydmslib.treelikelihood
              .TreeLikelihood(self.tree,
                              self.alignment,
                              self.model,
                              underflowfreq=self.underflowfreq,
                              dparamscurrent=False,
                              dtcurrent=True))
        self.assertEqual(tl.dloglik_dt.shape, tl.t.shape)

    def test_dM_dt(self):
        """Tests model `dM` with respect to `t`."""
        numpy.random.seed(1)
        random.seed(1)
        tl = (phydmslib.treelikelihood
              .TreeLikelihood(self.tree,
                              self.alignment,
                              self.model,
                              underflowfreq=self.underflowfreq,
                              dparamscurrent=False,
                              dtcurrent=True))

        def func(t, k, r, x, y):
            return tl._M(k, t[0], None)[r][x][y]

        def dfunc(t, k, r, x, y):
            return tl._dM(k, t[0], 't', None)[r][x][y]

        for r in range(self.nsites):
            k = random.choice(tl._catindices)
            x = random.randint(0, N_CODON - 1)

            y = random.randint(0, N_CODON - 1)