Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def describe(function):
return iminuit.describe(function)
def __init__(self, lossfunction):
self._lossfunction = lossfunction
self._parameters = describe(lossfunction)
lossattrs = dir(lossfunction)
model = next(a for a in lossattrs if a in ["model", "pdf", "f"])
if model is None:
raise ValueError("Model not found in loss function.")
self._model = getattr(lossfunction, model)
if not isinstance(self._model, ModelWrapper):
raise ValueError("Model need to be wrapped under\
statnight.utils.ModelWrapper.")
self._data = getattr(lossfunction, "data", None)
if self._data is None:
raise ValueError("Data not found in loss function.")
def __init__(self, model, Spaces=[], variables=[], extended=False):
"""
__init__ function
"""
hascall = hasattr(model, "__call__")
hasintegrate = hasattr(model, "integrate")
if not(hascall and hasintegrate):
msg = "{0} doesn't seem to be a model."
raise ValueError(msg.format(model))
self._model = model
self._parameters = describe(model)
self._extended = extended
self._obs = check_obs(Spaces)
self._vars = check_vars(variables)
self._check_params()
self.func_code = func_code(self.parameters)
def __init__(self, func, parameters=[]):
"""
__init__ function
"""
hascall = hasattr(func, "__call__")
hasintegrate = hasattr(func, "integrate")
if not(hascall and hasintegrate):
msg = "{0} doesn't seem to be a model."
raise ValueError(msg.format(func))
self._func = func
self._parameters = describe(func)
self.func_code = func_code(self.parameters)
self.extended = False