def __init__(self, prefs, kappa=<NUM_LIT>, omega=<NUM_LIT:0.5>, beta=<NUM_LIT:1.0>, mu=<NUM_LIT:1.0>,<EOL>phi=scipy.ones(N_NT) / N_NT,<EOL>freeparams=['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']):
self._nsites = len(prefs)<EOL>assert self.nsites > <NUM_LIT:0>, "<STR_LIT>"<EOL>assert all(map(lambda x: x in self.ALLOWEDPARAMS, freeparams)),"<STR_LIT>".format(<EOL>'<STR_LIT:U+002CU+0020>'.join(freeparams), '<STR_LIT:U+002CU+0020>'.join(self.ALLOWEDPARAMS))<EOL>self._freeparams = list(freeparams) <EOL>self.pi = scipy.ndarray((self.nsites, N_AA), dtype='<STR_LIT:float>')<EOL>assert (isinstance(prefs, list) and<EOL>all([isinstance(x, dict) for x in prefs])),"<STR_LIT>"<EOL>for r in range(self.nsites):<EOL><INDENT>assert set(prefs[r].keys()) == set(AA_TO_INDEX.keys()),"<STR_LIT>".format(r)<EOL>assert abs(<NUM_LIT:1> - sum(prefs[r].values())) <= ALMOST_ZERO,"<STR_LIT>".format(r)<EOL>for (a, aa) in INDEX_TO_AA.items():<EOL><INDENT>_checkParam('<STR_LIT>', prefs[r][aa], self.PARAMLIMITS, self.PARAMTYPES)<EOL>self.pi[r][a] = prefs[r][aa]<EOL><DEDENT>self.pi[r] /= self.pi[r].sum() <EOL><DEDENT>self.pi_codon = scipy.full((self.nsites, N_CODON), -<NUM_LIT:1>, dtype='<STR_LIT:float>')<EOL>self.ln_pi_codon = scipy.full((self.nsites, N_CODON), -<NUM_LIT:1>, dtype='<STR_LIT:float>')<EOL>self.piAx_piAy = scipy.full((self.nsites, N_CODON, N_CODON), -<NUM_LIT:1>,<EOL>dtype='<STR_LIT:float>')<EOL>_checkParam('<STR_LIT>', phi, self.PARAMLIMITS, self.PARAMTYPES)<EOL>assert abs(<NUM_LIT:1> - phi.sum()) <= ALMOST_ZERO, "<STR_LIT>"<EOL>self.phi = phi.copy()<EOL>self.phi /= self.phi.sum()<EOL>self._eta_from_phi()<EOL>self._mu = mu <EOL>self.kappa = kappa<EOL>self.omega = omega<EOL>self.beta = beta<EOL>for (name, value) in [('<STR_LIT>', self.kappa), ('<STR_LIT>', self.omega),<EOL>('<STR_LIT>', self.beta), ('<STR_LIT>', self.eta), ('<STR_LIT>', self.mu)]:<EOL><INDENT>_checkParam(name, value, self.PARAMLIMITS, self.PARAMTYPES)<EOL><DEDENT>self.piAx_piAy_beta = scipy.zeros((self.nsites, N_CODON, N_CODON),<EOL>dtype='<STR_LIT:float>')<EOL>self.ln_piAx_piAy_beta = scipy.zeros((self.nsites, N_CODON, N_CODON),<EOL>dtype='<STR_LIT:float>')<EOL>self.Prxy = scipy.zeros((self.nsites, N_CODON, N_CODON), dtype='<STR_LIT:float>')<EOL>self.prx = scipy.zeros((self.nsites, N_CODON), dtype='<STR_LIT:float>')<EOL>self.Qxy = scipy.zeros((N_CODON, N_CODON), dtype='<STR_LIT:float>')<EOL>self.Frxy = scipy.ones((self.nsites, N_CODON, N_CODON), dtype='<STR_LIT:float>')<EOL>self.Frxy_no_omega = scipy.ones((self.nsites, N_CODON, N_CODON),<EOL>dtype='<STR_LIT:float>')<EOL>self.D = scipy.zeros((self.nsites, N_CODON), dtype='<STR_LIT:float>')<EOL>self.A = scipy.zeros((self.nsites, N_CODON, N_CODON), dtype='<STR_LIT:float>')<EOL>self.Ainv = scipy.zeros((self.nsites, N_CODON, N_CODON), dtype='<STR_LIT:float>')<EOL>self.dPrxy = {}<EOL>self.B = {}<EOL>self.dprx = {}<EOL>for param in self.freeparams:<EOL><INDENT>if param == '<STR_LIT>':<EOL><INDENT>self.dprx['<STR_LIT>'] = <NUM_LIT:0.0><EOL><DEDENT>elif self.PARAMTYPES[param] == float:<EOL><INDENT>self.dPrxy[param] = scipy.zeros((self.nsites, N_CODON, N_CODON),<EOL>dtype='<STR_LIT:float>')<EOL>self.B[param] = scipy.zeros((self.nsites, N_CODON, N_CODON),<EOL>dtype='<STR_LIT:float>')<EOL>self.dprx[param] = scipy.zeros((self.nsites, N_CODON), dtype='<STR_LIT:float>')<EOL><DEDENT>else:<EOL><INDENT>assert self.PARAMTYPES[param][<NUM_LIT:0>] == scipy.ndarray<EOL>paramshape = self.PARAMTYPES[param][<NUM_LIT:1>]<EOL>assert len(paramshape) == <NUM_LIT:1>, "<STR_LIT>"<EOL>paramlen = paramshape[<NUM_LIT:0>]<EOL>self.dPrxy[param] = scipy.zeros((paramlen, self.nsites, N_CODON,<EOL>N_CODON), dtype='<STR_LIT:float>')<EOL>self.B[param] = scipy.zeros((paramlen, self.nsites, N_CODON,<EOL>N_CODON), dtype='<STR_LIT:float>')<EOL>self.dprx[param] = scipy.zeros((paramlen, self.nsites, N_CODON),<EOL>dtype='<STR_LIT:float>')<EOL><DEDENT><DEDENT>self._diag_indices = scipy.diag_indices(N_CODON)<EOL>self.updateParams({}, update_all=True)<EOL>
Initialize an `ExpCM` object.

        Args:
            `prefs` (list)
                List of dicts giving amino-acid preferences for
                each site. Each dict keyed by amino acid letter
                codes, value is pref > 0 and < 1. Must sum to 1
                at each site.
            `kappa`, `omega`, `beta`, `mu`, `phi`
                Model params described in main class doc string.
            `freeparams` (list of strings)
                Specifies free parameters.