def fit_constrained_wrap(model, constraints, start_params=None, **fit_kwds):
 self = model
 from patsy import DesignInfo
 lc = DesignInfo(self.exog_names).linear_constraint(constraints)
 (R, q) = (lc.coefs, lc.constants)
 (params, cov, res_constr) = fit_constrained(self, R, q, start_params=start_params, fit_kwds=fit_kwds)
 res = self.fit(start_params=params, maxiter=0, warn_convergence=False)
 res._results.params = params
 res._results.normalized_cov_params = cov
 k_constr = len(q)
 res._results.df_resid += k_constr
 res._results.df_model -= k_constr
 res._results.constraints = lc
 res._results.k_constr = k_constr
 res._results.results_constrained = res_constr
 return res

def fit_constrained_wrap ( model , constraints , start_params = None , ** fit_kwds ) : self = model from patsy import DesignInfo lc = DesignInfo ( self . exog_names ) . linear_constraint ( constraints ) ( R , q ) = ( lc . coefs , lc . constants ) ( params , cov , res_constr ) = fit_constrained ( self , R , q , start_params = start_params , fit_kwds = fit_kwds ) res = self . fit ( start_params = params , maxiter = 0 , warn_convergence = False ) res . _results . params = params res . _results . normalized_cov_params = cov k_constr = len ( q ) res . _results . df_resid += k_constr res . _results . df_model -= k_constr res . _results . constraints = lc res . _results . k_constr = k_constr res . _results . results_constrained = res_constr return res
fit_constraint that returns a results instance this is a development version for fit_constrained methods or fit_constrained as standalone function .