Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __call__(self, x):
new_args = map(lambda i: x[i], range(self._dimensions))
try:
f = self._function(*new_args)
except SettingOutOfBounds:
f = FIT_FAILED
if f == FIT_FAILED:
# Likelihood gave nan or other problems, we are likely in a forbidden
# space
fail = 1
else:
# Likelihood computation successful
fail = 0
def wrapper(x):
scaled_back_x = x * orders_of_magnitude # type: np.ndarray
try:
result = function(*scaled_back_x)
except SettingOutOfBounds:
raise CannotComputeHessian(
"Cannot compute Hessian, parameters out of bounds at %s" % scaled_back_x
)
else:
return result