Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.indep_fw, self.indep_bw = None, None
kwargs['linear_invariants'], kwargs['nonlinear_invariants'], \
kwargs['linear_invariant_names'], kwargs['nonlinear_invariant_names'] = _group_invariants(
all_invariants, dep, be, (list(kwargs.get('linear_invariant_names') or ()) +
list(kwargs.get('nonlinear_invariant_names') or ())))
lower_b = kwargs.pop('lower_bounds', None)
if lower_b is not None:
lower_b *= np.ones(len(dep))
upper_b = kwargs.pop('upper_bounds', None)
if upper_b is not None:
upper_b *= np.ones(len(dep))
pre_processors = kwargs.pop('pre_processors', [])
post_processors = kwargs.pop('post_processors', [])
super(TransformedSys, self).__init__(
zip(dep, exprs_process_cb(exprs) if exprs_process_cb is not None else exprs), indep, params, roots=roots,
pre_processors=pre_processors + [self._forward_transform_xy],
post_processors=[self._back_transform_out] + post_processors,
**kwargs)
# the pre- and post-processors need callbacks:
self.f_dep = None if self.dep_fw is None else self._callback_factory(self.dep_fw)
self.b_dep = None if self.dep_bw is None else self._callback_factory(self.dep_bw)
self.f_indep = None if self.indep_fw is None else self._callback_factory([self.indep_fw])
self.b_indep = None if self.indep_bw is None else self._callback_factory([self.indep_bw])
_x, _p = float('nan'), [float('nan')]*len(self.params)
self.lower_bounds = lower_b if self.f_dep is None or lower_b is None else self.f_dep(_x, lower_b, _p)
self.upper_bounds = upper_b if self.f_dep is None or upper_b is None else self.f_dep(_x, upper_b, _p)
**new_kwargs)
@classmethod
def from_callback(cls, cb, ny=None, nparams=None, **inner_kwargs):
new_kwargs = kwargs.copy()
new_kwargs.update(inner_kwargs)
return SuperClass.from_callback(
cb, ny, nparams,
dep_transf_cbs=repeat(dep_tr) if dep_tr is not None else None,
indep_transf_cbs=indep_tr,
**new_kwargs)
return _SymmetricSys
class ScaledSys(TransformedSys):
""" Transformed system where the variables have been scaled linearly.
Parameters
----------
dep_exprs : iterable of (symbol, expression)-pairs
see :class:`SymbolicSys`
indep : Symbol
see :class:`SymbolicSys`
dep_scaling : number (>0) or iterable of numbers
scaling of the dependent variables (default: 1)
indep_scaling : number (>0)
scaling of the independent variable (default: 1)
params :
see :class:`SymbolicSys`
\\*\\*kwargs :
Keyword arguments passed onto :class:`TransformedSys`.