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


import random
import unittest
import copy
import numpy
import scipy.optimize
import sympy
import phydmslib.models
from phydmslib.constants import N_AA, N_NT, AA_TO_INDEX
    def test_dlogprior(self):
        """Test `dlogprior`."""
        numpy.random.seed(1)

        expcm_fitprefs = copy.deepcopy(self.expcm_fitprefs)
        self.assertTrue(numpy.allclose(expcm_fitprefs.pi,
                                       expcm_fitprefs.origpi))
        if self.MODEL == phydmslib.models.ExpCM_fitprefs:
            newzeta = (expcm_fitprefs.zeta.copy() *
                       numpy.random.uniform(0.9, 1.0,
                                            expcm_fitprefs.zeta.shape))
        elif self.MODEL == phydmslib.models.ExpCM_fitprefs2:
            newzeta = (expcm_fitprefs.zeta.copy() *
                       numpy.random.uniform(0.01, 10.0,
                                            expcm_fitprefs.zeta.shape))
        else:
            raise RuntimeError("invalid MODEL: {0}".format(self.MODEL))
        expcm_fitprefs.updateParams({'zeta': newzeta})
        self.assertFalse(numpy.allclose(expcm_fitprefs.pi,
                                        expcm_fitprefs.origpi))
        nsites = expcm_fitprefs.nsites

        def func(zetari, i, r):
            zeta = expcm_fitprefs.zeta.copy()
            zeta.reshape(nsites, N_AA - 1)[r][i] = zetari
            expcm_fitprefs.updateParams({'zeta': zeta})
            return expcm_fitprefs.logprior

        def dfunc(zetari, i, r):
            zeta = expcm_fitprefs.zeta.copy()

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


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

    def test_dlogprior(self):
        """Test `dlogprior`."""
        numpy.random.seed(1)

        expcm_fitprefs = copy.deepcopy(self.expcm_fitprefs)
        self.assertTrue(numpy.allclose(expcm_fitprefs.pi,
                                       expcm_fitprefs.origpi))
        if self.MODEL == phydmslib.models.ExpCM_fitprefs:
            newzeta = (expcm_fitprefs.zeta.copy() *
                       numpy.random.uniform(0.9, 1.0,
                                            expcm_fitprefs.zeta.shape))
        elif self.MODEL == phydmslib.models.ExpCM_fitprefs2:
            newzeta = (expcm_fitprefs.zeta.copy() *
                       numpy.random.uniform(0.01, 10.0,
                                            expcm_fitprefs.zeta.shape))
        else:
            raise RuntimeError("invalid MODEL: {0}".format(self.MODEL))
        expcm_fitprefs.updateParams({'zeta': newzeta})
        self.assertFalse(numpy.allclose(expcm_fitprefs.pi,
                                        expcm_fitprefs.origpi))
        nsites = expcm_fitprefs.nsites

        def func(zetari, i, r):
            zeta = expcm_fitprefs.zeta.copy()
            zeta.reshape(nsites, N_AA - 1)[r][i] = zetari
            expcm_fitprefs.updateParams({'zeta': zeta})
            return expcm_fitprefs.logprior

        def dfunc(zetari, i, r):
            zeta = expcm_fitprefs.zeta.copy()

            zeta.reshape(nsites, N_AA - 1)[r][i] = zetari