This function zeroes the baseline from 2.5ppm upwards
420169
def baseline_correct(G):

    
    # define ppm ranges that are known to be at baseline, get indices
    baseidx =[]
    baseidx.extend(range(np.min(np.where(G.f_ppm<5.0)),np.max(np.where(G.f_ppm>4.0))+1))
    baseidx.extend(range(np.min(np.where(G.f_ppm<3.5)),np.max(np.where(G.f_ppm>3.2))+1))
    baseidx.extend(range(np.min(np.where(G.f_ppm<2.8)),np.max(np.where(G.f_ppm>2.5))+1))

    G.diff = np.mean(G.diff_spectra,0)
    # find x and y values at those indices
    yArr=np.real(G.diff[baseidx])
    baseppm = G.f_ppm[baseidx]
    # filter out anything above the new max
    adjbaseppm =[baseppm[i] for i in np.where(baseppm<=np.max(G.f_ppm))[0]]
    
    # spline
    f = interpolate.interp1d(adjbaseppm[::-1], yArr[::-1], kind='linear', bounds_error=True, fill_value=0)
    
    fitidxmax = np.where(G.f_ppm<np.max(adjbaseppm))[0]
    fitidxmin = np.where(G.f_ppm>np.min(adjbaseppm))[0]
    fitidx = list(set(fitidxmax) & set(fitidxmin))
    
    basefit = f(G.f_ppm[fitidx])#[::-1]
    adjusted = G.diff[fitidx]-basefit#[::-1]

    G.diff_corrected = G.diff
    G.diff_corrected[fitidx] = adjusted
    
    # tag as corrected
    G.baseline_corrected = True
1144573
def pct_negative(self, threshold=0.0):
        

        return np.count_nonzero(self[self < threshold]) / self.count()
560392
def set_baselines(self):
        
        if self.style.xbaseline:
            if self.style.orient in ("up", "down"):
                self.coords.coords[:, 0] += self.style.xbaseline
                self.coords.verts[:, 0] += self.style.xbaseline                
            else:
                self.coords.coords[:, 1] += self.style.xbaseline
                self.coords.verts[:, 1] += self.style.xbaseline
771007
def position_half_h(pslit, cpix, backw=4):
    """"""

    # Find the first peak to the right of cpix
    next_peak = simple_prot(pslit, cpix)

    if next_peak is None:
        raise ValueError

    dis_peak = next_peak - cpix

    wpos2 = cpix - dis_peak
    wpos1 = wpos2 - backw

    # Compute background in a window of width backw
    # in a position simetrical to the peak
    # around cpix
    left_background = pslit[wpos1:wpos2].min()

    # height of the peak
    height = pslit[next_peak] - left_background

    half_height = left_background + 0.5 * height

    # Position at halg peak, linear interpolation
    vv = pslit[wpos1:next_peak+1] - half_height

    res1, =  numpy.nonzero(numpy.diff(vv > 0))
    i1 = res1[0]

    xint = wpos1 + i1 + (0 - vv[i1]) / (vv[i1+1] - vv[i1])

    return xint, next_peak, wpos1, wpos2, left_background, half_height
705476
public void setZero() {
		xx = 0.0;
		yx = 0.0;
		zx = 0.0;
		xy = 0.0;
		yy = 0.0;
		zy = 0.0;
		xz = 0.0;
		yz = 0.0;
		zz = 0.0;
		xd = 0.0;
		yd = 0.0;
		zd = 0.0;
	}
217242
def condense_multidimensional_zeros(css):
    """"""

    css = css.replace(":0 0 0 0;", ":0;")
    css = css.replace(":0 0 0;", ":0;")
    css = css.replace(":0 0;", ":0;")

    # Revert `background-position:0;` to the valid `background-position:0 0;`.
    css = css.replace("background-position:0;", "background-position:0 0;")

    return css
151499
def optimize_no(self):
        ''' 
        '''
        self.optimization = 0
        self.relax = False
        self.gc_sections = False
        self.ffunction_sections = False
        self.fdata_sections = False
        self.fno_inline_small_functions = False
160706
function MixSilenceIntoBuf(ch, start, end, dataL, dataR) {
  var s = ch.filterstate[1];
  if (isNaN(s)) {
    console.log("NaN filterstate?", ch.filterstate, ch.filter);
    return;
  }
  for (var i = start; i < end; i++) {
    if (Math.abs(s) < 1.526e-5) {  // == 1/65536.0
      s = 0;
      break;
    }
    dataL[i] += s * ch.vL;
    dataR[i] += s * ch.vR;
    s *= popfilter_alpha;
  }
  ch.filterstate[1] = s;
  ch.filterstate[2] = s;
  if (isNaN(s)) {
    console.log("NaN filterstate after adding silence?", ch.filterstate, ch.filter, i);
    return;
  }
  return 0;
}
1051037
def prox_zero(X, step):
    
    return np.zeros(X.shape, dtype=X.dtype)
862124
def autoscale(bp, optimal=6):
    
    slen = str(bp)
    tlen = slen[0:2] if len(slen) > 1 else slen[0]
    precision = len(slen) - 2  # how many zeros we need to pad?
    bp_len_scaled = int(tlen)  # scale bp_len to range (0, 100)
    tick_diffs = [(x, abs(bp_len_scaled / x - optimal)) for x in [1, 2, 5, 10]]
    best_stride, best_tick_diff = min(tick_diffs, key=lambda x: x[1])

    while precision > 0:
        best_stride *= 10
        precision -= 1

    return best_stride
675246
def lessgreater(x, y):
    
    x = BigFloat._implicit_convert(x)
    y = BigFloat._implicit_convert(y)
    return mpfr.mpfr_lessgreater_p(x, y)
909980
def inverse_lin_decay(max_step, min_value=0.01, step=None):
  """"""
  if step is None:
    step = tf.train.get_global_step()
  if step is None:
    return 1.0
  step = to_float(step)
  progress = tf.minimum(step / float(max_step), 1.0)
  return progress * (1.0 - min_value) + min_value
876111
def analog_linear2_ramp(ramp_data, start_time, end_time, value_final,
                       time_subarray):
    """"""
    value_initial = ramp_data["value"]
    value_final2 = ramp_data["value_final"]
    interp = (time_subarray - start_time)/(end_time - start_time)
    return value_initial*(1.0 - interp) + value_final2*interp
653355
def getLinearityFunction(expTimes, imgs, mxIntensity=65535, min_ascent=0.001,
                         ):
    '''
    
    '''
    # TODO: calculate [min_ascent] from noise function
    # instead of having it as variable

    ascent, offset, error = linRegressUsingMasked2dArrays(
        expTimes, imgs, imgs > mxIntensity)

    ascent[np.isnan(ascent)] = 0
    # remove low frequent noise:
    if min_ascent > 0:
        i = ascent < min_ascent
        offset[i] += (0.5 * (np.min(expTimes) + np.max(expTimes))) * ascent[i]
        ascent[i] = 0

    return offset, ascent, error
1177331
def lowshelf(self, gain=-20.0, frequency=100, slope=0.5):
        
        self.command.append('bass')
        self.command.append(gain)
        self.command.append(frequency)
        self.command.append(slope)
        return self
28396
def atanh(x, context=None):
    
    return _apply_function_in_current_context(
        BigFloat,
        mpfr.mpfr_atanh,
        (BigFloat._implicit_convert(x),),
        context,
    )
517131
function () {
            var t = this.dpop() | 0;
            var ttt = Long.fromInt(t);
            this.dpush(ttt.low);
            this.dpush(ttt.high);
        }