Calculate the integral scale of a time series by integrating up to
    the first zero crossing.
776443
def integral_scale(u, t, tau1=0.0, tau2=1.0):
    
    tau, rho = autocorr_coeff(u, t, tau1, tau2)
    zero_cross_ind = np.where(np.diff(np.sign(rho)))[0][0]
    int_scale = np.trapz(rho[:zero_cross_ind], tau[:zero_cross_ind])
    return int_scale
145526
def intround(value):
    

    return int(decimal.Decimal.from_float(
        value).to_integral_value(decimal.ROUND_HALF_EVEN))
96820
def integratedAutocorrelationTime(A_n, B_n=None, fast=False, mintime=3):
    

    g = statisticalInefficiency(A_n, B_n, fast, mintime)
    tau = (g - 1.0) / 2.0
    return tau
998647
def hilbert(ts):
    """"""
    output = signal.hilbert(signal.detrend(ts, axis=0), axis=0)
    return Timeseries(output, ts.tspan, labels=ts.labels)
20645
def handle_zeros_in_scale(scale, copy=True):
    ''' '''

    # if we are fitting on 1D arrays, scale might be a scalar
    if np.isscalar(scale):
        if scale == .0:
            scale = 1.
        return scale
    elif isinstance(scale, np.ndarray):
        if copy:
            # New array to avoid side-effects
            scale = scale.copy()
        scale[scale == 0.0] = 1.0
    return scale
169905
def _slow_calcbinflux(len_binwave, i_beg, i_end, avflux, deltaw):
    
    binflux = np.empty(shape=(len_binwave, ), dtype=np.float64)
    intwave = np.empty(shape=(len_binwave, ), dtype=np.float64)

    # Note that, like all Python striding, the range over which
    # we integrate is [first:last).
    for i in range(len(i_beg)):
        first = i_beg[i]
        last = i_end[i]
        cur_dw = deltaw[first:last]
        intwave[i] = cur_dw.sum()
        binflux[i] = np.sum(avflux[first:last] * cur_dw) / intwave[i]

    return binflux, intwave
421658
function integral(x0, x1, slope, intercept) {
                return (0.5 * slope * x1 * x1 + intercept * x1) - (0.5 * slope * x0 * x0 + intercept * x0);
            }
829618
def _init_a(D):
    ''''''
    E = D.mean(axis=0)
    E2 = (D**2).mean(axis=0)
    return ((E[0] - E2[0])/(E2[0]-E[0]**2)) * E
678871
def step(self, t, x_im1, v_im1_2, dt):
        

        x_i = x_im1 + v_im1_2 * dt
        F_i = self.F(t, np.vstack((x_i, v_im1_2)), *self._func_args)
        a_i = F_i[self.ndim:]

        v_i = v_im1_2 + a_i * dt / 2
        v_ip1_2 = v_i + a_i * dt / 2

        return x_i, v_i, v_ip1_2
703224
def _sumSeries(a: float, b: float, steps: int) -> float:
        
        return a * (exp(b * steps) - 1) / (exp(b) - 1)
1341480
def _interpolate(self, kind='linear'):
        """"""
        # drop any existing non-dimension coordinates along the resampling
        # dimension
        dummy = self._obj.copy()
        for k, v in self._obj.coords.items():
            if k != self._dim and self._dim in v.dims:
                dummy = dummy.drop(k)
        return dummy.interp(assume_sorted=True, method=kind,
                            kwargs={'bounds_error': False},
                            **{self._dim: self._full_index})
555727
def scale(self, scalar):
        ''''''
        return self.__class__([self.coefficients[i] * scalar for i in _range(len(self))])
1033131
def autoscale(self):
        
        # requires matplotlib >= 0.98.0
        (vmin, vmax) = self.axis.get_data_interval()

        locs = self._get_default_locs(vmin, vmax)
        (vmin, vmax) = locs[[0, -1]]
        if vmin == vmax:
            vmin -= 1
            vmax += 1
        return nonsingular(vmin, vmax)
326036
def _integrate_variable_trajectory(self, h, g, tol, step, relax):
        """"""
        # initialize the solution using initial condition
        solution = np.hstack((self.t, self.y))

        while self.successful():

            self.integrate(self.t + h, step, relax)
            current_step = np.hstack((self.t, self.y))
            solution = np.vstack((solution, current_step))

            if g(self.t, self.y, *self.f_params) < tol:
                break
            else:
                continue

        return solution
690649
def scale(p, factor, o=(0, 0)):
    
    v = vector(o, p)
    sv = v[0] * factor, v[1] * factor
    return translate(sv, o)
1082079
def feature_scaling(x, xmin, xmax, a=0, b=1):
    ''''''
    return a + float(x - xmin) * (b - a) / (xmax - xmin)
1341965
def mean(self, series, start, limit):
        '''
        
        '''
        return float(np.mean(series[start:limit]))