def quadraticFit(derivative,ext):
    '''
    Find an extremum in the data and use it and the points on either side, fit
    a quadratic function to the three points, and return the x-position of the 
    apex of the best-fit parabola. 
    
    Called by oscaar.trackSmooth()
    
    Parameters
    ----------
    derivative : numpy.ndarray
       The first derivative of the series of points, usually calculated by np.diff()
                    
    ext : string 
        Extremum to look find. May be either "max" or "min"
    
    Returns
    -------
    extremum : float
        The (non-integer) index where the extremum was found
       
    '''
    rangeOfFit = 1
    lenDer = len(derivative)/2
    if ext == "max":
        indExtrema = np.argmax(derivative[:lenDer])
    elif ext == "min":
        indExtrema = np.argmin(derivative[lenDer:])+lenDer

    fitPart = derivative[indExtrema-rangeOfFit:indExtrema+rangeOfFit+1]
    if len(fitPart) == 3:
        stackPolynomials = np.zeros([3,3])
        for i in range(0,len(fitPart)):
            stackPolynomials[i,:] = [i**2,i,1.0]
        estimatedCoeffs = np.dot(LA.inv(stackPolynomials),fitPart)
        d_fit = -estimatedCoeffs[1]/(2.0*estimatedCoeffs[0])            #d_fit = -b_fit/(2.*a_fit)
        extremum = d_fit+rangeOfFit-indExtrema
    else: 
        extremum = indExtrema
    return extremum
dataset/ETHPy150Open OSCAAR/OSCAAR/oscaar/astrometry/trackSmooth.py/quadraticFit/swapped operands of `-`