Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_jtimes_callback(self):
""" Generate a callback fro evaluating the jacobian-vector product."""
jtimes = self.get_jtimes()
if jtimes is False:
return None
v, jtimes_exprs = jtimes
return _Callback(self.indep, tuple(self.dep) + tuple(v), self.params,
jtimes_exprs, Lambdify=self.be.Lambdify)
def _get_analytic_callback(ori_sys, analytic_exprs, new_dep, new_params):
return _Callback(ori_sys.indep, new_dep, new_params, analytic_exprs, Lambdify=ori_sys.be.Lambdify)
def _callback_factory(self, exprs):
return _Callback(self.indep, self.dep, self.params, exprs, Lambdify=self.be.Lambdify)
new_latex_par_names : iterable of str
TeX formatted names of the new parameters given in ``new_pars``.
\\*\\*kwargs:
Keyword arguments passed to ``.from_other``.
Returns
-------
Intance of the class
extra : dict with keys:
- recalc_params : ``f(t, y, p1) -> p0``
"""
new_exprs = [expr.subs(par_subs) for expr in ori.exprs]
drop_idxs = [ori.params.index(par) for par in par_subs]
params = _skip(drop_idxs, ori.params, False) + list(new_pars)
back_substitute = _Callback(ori.indep, ori.dep, params, list(par_subs.values()),
Lambdify=ori.be.Lambdify)
def recalc_params(t, y, p):
rev = back_substitute(t, y, p)
return _reinsert(drop_idxs, np.repeat(np.atleast_2d(p), rev.shape[0], axis=0),
rev)[..., :len(ori.params)]
return cls.from_other(
ori, dep_exprs=zip(ori.dep, new_exprs),
params=params,
param_names=_skip(drop_idxs, ori.param_names, False) + list(new_par_names or []),
latex_param_names=_skip(drop_idxs, ori.latex_param_names, False) + list(new_latex_par_names or []),
**kwargs
), {'recalc_params': recalc_params}