def fitFunction(iniParameters):
    global function
    global x
    global y
    global y_err
    global numberOfDataPoints
    global numberOfParameters
    global fitStructure
    global fitParameters
    global fitErrors
    if (numberOfDataPoints < numberOfParameters):
        return 2
    try:
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore')
            fitStructure = opt.curve_fit(functions[function].func, x, y, absolute_sigma=True, p0=iniParameters, sigma=y_err)
    except RuntimeError as e:
        if str(e).startswith('Optimal parameters not found: Number of calls to function has reached maxfev'):
            return 1
        else:
            raise
    fitParameters = fitStructure[0]
    fitErrors = np.sqrt(np.diag(fitStructure[1]))
    calcGoodnessOfFit()
    return 0
def fitFunction(iniParameters):
    global function
    global x
    global y
    global y_err
    global numberOfDataPoints
    global numberOfParameters
    global fitStructure
    global fitParameters
    global fitErrors
    if (numberOfDataPoints < numberOfParameters):
        return 2
    try:
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore')
            fitStructure = opt.curve_fit(functions[function].func, x, y, absolute_sigma=True, p0=iniParameters, sigma=y_err)
    except RuntimeError as e:
        if str(e).startswith('Optimal parameters not found: Number of calls to function has reached maxfev'):
            return 1
        else:
            raise
    fitParameters = fitStructure[0]
    fitErrors = np.sqrt(np.diag(fitStructure[1]))
    calcGoodnessOfFit()
    return 0