def updateParams(self, newvalues, update_all=False):
assert all(map(lambda x: x in self.freeparams, newvalues.keys())),"<STR_LIT>".format(<EOL>'<STR_LIT:U+002CU+0020>'.join(newvalues.keys()), '<STR_LIT:U+002CU+0020>'.join(self.freeparams))<EOL>newvalues_list = [{} for k in range(self.ncats)]<EOL>if update_all or any([param in self.distributionparams for param<EOL>in newvalues.keys()]):<EOL><INDENT>self._d_distributionparams = {}<EOL>for param in self.distributionparams:<EOL><INDENT>if param in newvalues:<EOL><INDENT>_checkParam(param, newvalues[param], self.PARAMLIMITS,<EOL>self.PARAMTYPES)<EOL>setattr(self, param, copy.copy(newvalues[param]))<EOL><DEDENT><DEDENT>self._lambdas = DiscreteGamma(self.alpha_lambda, self.beta_lambda,<EOL>self.ncats)<EOL>for (k, l) in enumerate(self._lambdas):<EOL><INDENT>newvalues_list[k][self.distributedparam] = l<EOL><DEDENT><DEDENT>for name in self.freeparams:<EOL><INDENT>if name not in self.distributionparams:<EOL><INDENT>if name in newvalues:<EOL><INDENT>value = newvalues[name]<EOL>_checkParam(name, value, self.PARAMLIMITS, self.PARAMTYPES)<EOL>setattr(self, name, copy.copy(value))<EOL>for k in range(self.ncats):<EOL><INDENT>newvalues_list[k][name] = value<EOL><DEDENT><DEDENT>elif update_all:<EOL><INDENT>for k in range(self.ncats):<EOL><INDENT>newvalues_list[k][name] = getattr(self, name)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>assert len(newvalues_list) == len(self._models) == self.ncats<EOL>for (k, newvalues_k) in enumerate(newvalues_list):<EOL><INDENT>self._models[k].updateParams(newvalues_k)<EOL><DEDENT>for param in self.freeparams:<EOL><INDENT>if param not in self.distributionparams:<EOL><INDENT>pvalue = getattr(self, param)<EOL>assert all([scipy.allclose(pvalue, getattr(model, param))<EOL>for model in self._models]), ("<STR_LIT>".format(<EOL>pvalue, '<STR_LIT:\n>'.join([str(getattr(model, param))<EOL>for model in self._models])))<EOL><DEDENT><DEDENT>
See docs for `Model` abstract base class.