Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _bounds_wrapper(t, y, p=(), be=None):
if lb is not None:
if np.any(y < lb - 10*self._current_integration_kwargs['atol']):
raise RecoverableError
y = np.array(y)
y[y < lb] = lb[y < lb]
if ub is not None:
if np.any(y > ub + 10*self._current_integration_kwargs['atol']):
raise RecoverableError
y = np.array(y)
y[y > ub] = ub[y > ub]
return cb(t, y, p, be)
return _bounds_wrapper
def _f(x, y, fout):
try:
if len(_p) > 0:
fout[:] = np.asarray(self.f_cb(x, y, _p))
else:
fout[:] = np.asarray(self.f_cb(x, y))
except RecoverableError:
return 1 # recoverable error