returns df/dx and df/dy of the function
333196
def derivatives(self, x, y, coeffs, beta, center_x=0, center_y=0):
        
        shapelets = self._createShapelet(coeffs)
        n_order = self._get_num_n(len(coeffs))
        dx_shapelets = self._dx_shapelets(shapelets, beta)
        dy_shapelets = self._dy_shapelets(shapelets, beta)
        n = len(np.atleast_1d(x))
        if n <= 1:
            f_x = self._shapeletOutput(x, y, beta, dx_shapelets, precalc=False)
            f_y = self._shapeletOutput(x, y, beta, dy_shapelets, precalc=False)
        else:
            H_x, H_y = self.pre_calc(x, y, beta, n_order+1, center_x, center_y)
            f_x = self._shapeletOutput(H_x, H_y, beta, dx_shapelets)
            f_y = self._shapeletOutput(H_x, H_y, beta, dy_shapelets)
        return f_x, f_y
5936
def results(self):
        """"""
        if self.deriv == 0:
            return self.v,
        if self.deriv == 1:
            return self.v, self.d
        if self.deriv == 2:
            return self.v, self.d, self.dd
1063410
def _deriv_logaddexp(x1, x2):
    """"""
    y1 = np.exp(x1)
    y2 = np.exp(x2)
    df_dx1 = y1 / (y1 + y2)
    df_dx2 = y2 / (y1 + y2)
    return np.vstack([df_dx1, df_dx2]).T
130980
def object_apply(self, function):
        '''
        
        '''
        return pd.concat([function(df) for _, df in self.groupby(self._oid)])
326598
def _derZ(self,x,y,z):
        '''
        
        '''
        m = len(x)
        temp = np.zeros((m,self.funcCount))
        for j in range(self.funcCount):
            temp[:,j] = self.functions[j](x,y,z)
        temp[np.isnan(temp)] = np.inf
        i = np.argmin(temp,axis=1)
        y = temp[np.arange(m),i]
        dfdz = np.zeros_like(x)
        for j in range(self.funcCount):
            c = i == j
            dfdz[c] = self.functions[j].derivativeZ(x[c],y[c],z[c])
        return dfdz
1129318
def std(self) -> Optional[float]:  #, ddof=0):
        
        # TODO: Add DOF
        if self._stats:
            return np.sqrt(self.variance())
        else:
            return None
665545
def D(self):
        '''
        
        '''
        return Point(self.minX, self.maxY, self.origin.z)
322247
def vcf_as_df(fn):
    
    header_lines = 0
    with open(fn, 'r') as f:
        line = f.readline().strip()
        header_lines += 1
        while line[0] == '#':
            line = f.readline().strip()
            header_lines += 1
    
    header_lines -= 2
    df = pd.read_table(fn, skiprows=header_lines, header=0)
    df.columns = ['CHROM'] + list(df.columns[1:])
    return df
223943
def to_df(self):
        ''''''
        return pd.DataFrame({k: v for k, v in self.items() if k is not 'names'},
                            index=self['names'])
552646
def eval_objfn(self):
        

        dfd = self.obfn_dfd()
        reg = self.obfn_reg()
        obj = dfd + reg[0]
        return (obj, dfd) + reg[1:]
1267262
def _get_kdjd(cls, df, n_days):
        
        k_column = 'kdjk_{}'.format(n_days)
        d_column = 'kdjd_{}'.format(n_days)
        df[d_column] = list(cls._calc_kd(df.get(k_column)))
999199
def get_info(df, verbose = None,max_cols = None, memory_usage = None, null_counts = None):
    
    assert type(df) is pd.DataFrame
    buffer = io.StringIO()
    df.info(verbose, buffer, max_cols, memory_usage, null_counts)
    return buffer.getvalue()
636758
def list_parameters_as_df(self):
        
        to_df = []

        for i, e in enumerate(self.ext_params):
            row = {}
            row['id'] = e['name']
            row['coords'] = "n/a"
            row['description'] = e['description']
            row['function'] = "n/a"

            to_df.append(row)

        for pk in self.params:
            p = self.params[pk]
            row = {}
            row['id'] = pk
            row['coords'] = p['coords']
            row['description'] = p['description']
            row['function'] = p['function']

            to_df.append(row)

        df = pd.DataFrame(to_df)
        
        return df
227857
def get_value(self):
        """"""
        # It is import to avoid accessing Qt C++ object as it has probably
        # already been destroyed, due to the Qt.WA_DeleteOnClose attribute
        df = self.dataModel.get_data()
        if self.is_series:
            return df.iloc[:, 0]
        else:
            return df
1287774
def df(self):
        
        data = self._final_data()
        
        if len(data) == 0:
            adf = pd.DataFrame(columns = [self.index.name, self.name])
            return adf.set_index(self.index.name)
            
        adf = pd.DataFrame(data)
        
        if len(adf.columns) != 2:
            msg = "Symbol ({}) needs to be cached prior to building a Dataframe"
            msg = msg.format(self.name)
            raise Exception(msg)
        adf.columns = [self.index.name, self.name]
        return self._finish_df(adf, 'FINAL')
500672
def sde(self):
        
        variance = float(self.variance.values)
        lengthscale = float(self.lengthscale.values)
        foo  = np.sqrt(3.)/lengthscale
        F    = np.array([[0, 1], [-foo**2, -2*foo]])
        L    = np.array([[0], [1]])
        Qc   = np.array([[12.*np.sqrt(3) / lengthscale**3 * variance]])
        H    = np.array([[1, 0]])
        Pinf = np.array([[variance, 0],
        [0,              3.*variance/(lengthscale**2)]])
        # Allocate space for the derivatives
        dF    = np.empty([F.shape[0],F.shape[1],2])
        dQc   = np.empty([Qc.shape[0],Qc.shape[1],2])
        dPinf = np.empty([Pinf.shape[0],Pinf.shape[1],2])
        # The partial derivatives
        dFvariance       = np.zeros([2,2])
        dFlengthscale    = np.array([[0,0],
        [6./lengthscale**3,2*np.sqrt(3)/lengthscale**2]])
        dQcvariance      = np.array([12.*np.sqrt(3)/lengthscale**3])
        dQclengthscale   = np.array([-3*12*np.sqrt(3)/lengthscale**4*variance])
        dPinfvariance    = np.array([[1,0],[0,3./lengthscale**2]])
        dPinflengthscale = np.array([[0,0],
        [0,-6*variance/lengthscale**3]])
        # Combine the derivatives
        dF[:,:,0]    = dFvariance
        dF[:,:,1]    = dFlengthscale
        dQc[:,:,0]   = dQcvariance
        dQc[:,:,1]   = dQclengthscale
        dPinf[:,:,0] = dPinfvariance
        dPinf[:,:,1] = dPinflengthscale

        return (F, L, Qc, H, Pinf, dF, dQc, dPinf)
71446
def derivative(xdata, ydata):
    
    D_ydata = []
    D_xdata = []
    for n in range(1, len(xdata)-1):
        D_xdata.append(xdata[n])
        D_ydata.append((ydata[n+1]-ydata[n-1])/(xdata[n+1]-xdata[n-1]))

    return [D_xdata, D_ydata]