# Path: phydmslib/constants.py
# ALMOST_ZERO = 1.0e-6
# 
# CODON_TO_INDEX = {}
# 
# N_CODON = len(CODON_TO_INDEX)


import copy
import warnings
import numpy
import scipy.optimize
import Bio.Phylo
import phydmslib.models
    import doctest
from phydmslib.numutils import broadcastMatrixVectorMultiply
from phydmslib.constants import ALMOST_ZERO, CODON_TO_INDEX, N_CODON

        def tfunc(x):
            """Negative log likelihood when `x` is branch lengths."""
            self.t = x
            return -self.loglik

        def tdfunc(x):
            """Negative gradient loglik with respect to branch lengths."""
            self.t = x
            return -self.dloglik_dt

        def _printResult(opttype, result, i, old, new):
            """Print summary of optimization result."""
            if printfunc is not None:
                printfunc('Step {0}, optimized {1}.\n'
                          'Likelihood went from {2} to {3}.\n'
                          'Max magnitude in Jacobian is {4}.\n'
                          'Full optimization result:\n{5}\n'
                          .format(i, opttype, old, new,
                                  numpy.absolute(result.jac).max(), result))

        oldloglik = self.loglik
        converged = False
        firstbrlenpass = True
        options = {'ftol': 1.0e-7}  # optimization options
        params_args = {'method': 'L-BFGS-B',
                       "bounds": self.paramsarraybounds,
                       "options": options
                       }
        tree_args = {'method': 'L-BFGS-B',

# Path: phydmslib/constants.py
# ALMOST_ZERO = 1.0e-6
# 
# CODON_TO_INDEX = {}
# 
# N_CODON = len(CODON_TO_INDEX)


# Path: phydmslib/treelikelihood.py
import copy
import warnings
import numpy
import scipy.optimize
import Bio.Phylo
import phydmslib.models
    import doctest
from phydmslib.numutils import broadcastMatrixVectorMultiply
from phydmslib.constants import ALMOST_ZERO, CODON_TO_INDEX, N_CODON


        def tfunc(x):
            """Negative log likelihood when `x` is branch lengths."""
            self.t = x
            return -self.loglik

        def tdfunc(x):
            """Negative gradient loglik with respect to branch lengths."""
            self.t = x
            return -self.dloglik_dt

        def _printResult(opttype, result, i, old, new):
            """Print summary of optimization result."""
            if printfunc is not None:
                printfunc('Step {0}, optimized {1}.\n'
                          'Likelihood went from {2} to {3}.\n'
                          'Max magnitude in Jacobian is {4}.\n'
                          'Full optimization result:\n{5}\n'
                          .format(i, opttype, old, new,
                                  numpy.absolute(result.jac).max(), result))

        oldloglik = self.loglik
        converged = False
        firstbrlenpass = True
        options = {'ftol': 1.0e-7}  # optimization options
        params_args = {'method': 'L-BFGS-B',
                       "bounds": self.paramsarraybounds,
                       "options": options
                       }
        tree_args = {'method': 'L-BFGS-B',

                     'bounds': [(ALMOST_ZERO, None)] * len(self.t),