helper function to bump a statistic
1468
def _increment(self, what, host):
        '''  '''

        self.processed[host] = 1
        prev = (getattr(self, what)).get(host, 0)
        getattr(self, what)[host] = prev+1
687711
def unpickle_stats(stats):
    """"""
    stats = cPickle.loads(stats)
    stats.stream = True
    return stats
1098311
def standardize_snps(G):
    
    """
    mean = G.mean(0)
    std = G.std(0)
    return (G - mean) / std
852545
def _update_general_statistics(a_float, dist):
    
    if not dist.count:
        dist.count = 1
        dist.maximum = a_float
        dist.minimum = a_float
        dist.mean = a_float
        dist.sumOfSquaredDeviation = 0
    else:
        old_count = dist.count
        old_mean = dist.mean
        new_mean = ((old_count * old_mean) + a_float) / (old_count + 1)
        delta_sum_squares = (a_float - old_mean) * (a_float - new_mean)
        dist.count += 1
        dist.mean = new_mean
        dist.maximum = max(a_float, dist.maximum)
        dist.minimum = min(a_float, dist.minimum)
        dist.sumOfSquaredDeviation += delta_sum_squares
936468
def flag_calcmad(data):
    

    absdev = np.abs(data - np.median(data))
    return np.median(absdev)
1372395
def loadCurve(data, groups, thresholds, absvals, fs, xlabels):
        """"""
        xlims = (xlabels[0], xlabels[-1])
        pw = ProgressWidget(groups, xlims)
        spike_counts = []
        # skip control
        for itrace in range(data.shape[0]):
            count = 0
            for ichan in range(data.shape[2]):
                flat_reps = data[itrace,:,ichan,:].flatten()
                count += len(spikestats.spike_times(flat_reps, thresholds[ichan], fs, absvals[ichan]))
            spike_counts.append(count/(data.shape[1]*data.shape[2])) #mean spikes per rep

        i = 0
        for g in groups:
            for x in xlabels:
                pw.setPoint(x, g, spike_counts[i])
                i +=1

        return pw
830304
def impute_data(self,x):
        """"""
        imp = Imputer(missing_values='NaN', strategy='mean', axis=0)
        return imp.fit_transform(x)
1050598
function modifyStatsObject ( stats, path ) {
  stats.path = path;
  stats.basename = fs.basename(path);
  stats.dirname = fs.dirname(path);
  stats.extname = fs.extname(path);
  return stats;
}
538156
def flatten(cls, stats):
        """"""
        flat_children = {}
        for _stats in spread_stats(stats):
            key = (_stats.name, _stats.filename, _stats.lineno, _stats.module)
            try:
                flat_stats = flat_children[key]
            except KeyError:
                flat_stats = flat_children[key] = cls(*key)
            flat_stats.own_hits += _stats.own_hits
            flat_stats.deep_hits += _stats.deep_hits
            flat_stats.own_time += _stats.own_time
            flat_stats.deep_time += _stats.deep_time
        children = list(itervalues(flat_children))
        return cls(stats.name, stats.filename, stats.lineno, stats.module,
                   stats.own_hits, stats.deep_hits, stats.own_time,
                   stats.deep_time, children)
105858
function wrap(stats, callback) {
  return function(err, content) {
    if (err) {
      return callback(err);
    }
    stats.content = content;
    return callback(null, stats);
  };
}
163271
def bump(dev=False, patch=False, minor=False, major=False, nocommit=False):
    """"""
    if sum([int(x) for x in (patch, minor, major)]) > 1:
        raise ValueError('Only one of patch, minor, major can be incremented.')

    if check_staged():
        raise EnvironmentError('There are staged changes, abort.')

    with open(str(INIT_PATH)) as f:
        lines = f.readlines()

    for i, line in enumerate(lines):
        varmatch = re.match("__([a-z]+)__ = '([^']+)'", line)
        if varmatch:
            if varmatch.group(1) == 'version':
                version = Version(varmatch.group(2))
                vdict = version._version._asdict()
                print('Current version:', version)
                increment_release = True
                if dev:
                    if vdict['dev']:
                        vdict['dev'] = (vdict['dev'][0], vdict['dev'][1] + 1)
                        increment_release = False
                        if sum([int(x) for x in (patch, minor, major)]) > 0:
                            raise ValueError('Cannot increment patch, minor, or major between dev versions.')
                    else:
                        vdict['dev'] = ('dev', 0)
                else:
                    if vdict['dev']:
                        vdict['dev'] = None
                        increment_release = False

                if increment_release:
                    rel = vdict['release']
                    if major:
                        vdict['release'] = (rel[0] + 1, 0, 0)
                    elif patch:
                        vdict['release'] = (rel[0], rel[1], rel[2] + 1)
                    else:  # minor is default
                        vdict['release'] = (rel[0], rel[1] + 1, 0)

                version._version = _Version(**vdict)
                print('Version bumped to:', version)
                lines[i] = "__version__ = '{!s}'\n".format(version)
                break

    with open(str(INIT_PATH), 'w') as f:
        f.writelines(lines)

    if not nocommit:
        call(['git', 'add', 'bucketcache/__init__.py'])
        call(['git', 'commit', '-m', 'Bumped version number to {!s}'.format(version)])
    return version
650814
function bump(type) {
    if (type === void 0) { type = 'patch'; }
    var _pkg = pkg();
    if (!_pkg || !_pkg.version)
        logger_1.log.error('failed to load package.json, are you sure this is a valid project?');
    var origVer = _pkg.version;
    var newVer = semver_1.inc(origVer, type);
    if (newVer === null)
        logger_1.log.error('Whoops tried to bump version but got null.');
    _pkg.version = newVer;
    pkg(_pkg);
    return { name: _pkg.name, version: _pkg.version, previous: origVer, current: _pkg.version };
}
577096
function nodup(eq) {
    let last
    if (arguments.length===0)
        eq = (a,b)=>a===b
    return function(v, cur){
        if ( !eq(last, cur) )
            v.push(cur)
        last=cur
        return v
    }
}
1006044
def calculate_up_moves(high_data):
    
    up_moves = [high_data[idx] - high_data[idx-1] for idx in range(1, len(high_data))]
    return [np.nan] + up_moves
139501
def double_smoothed_stochastic(data, period):
    
    catch_errors.check_for_period_error(data, period)
    lows = [data[idx] - np.min(data[idx+1-period:idx+1]) for idx in range(period-1, len(data))]
    sm_lows = ema(ema(lows, period), period)
    highs = [np.max(data[idx+1-period:idx+1]) - np.min(data[idx+1-period:idx+1]) for idx in range(period-1, len(data))]
    sm_highs = ema(ema(highs, period), period)
    dss = (sm_lows / sm_highs) * 100

    dss = fill_for_noncomputable_vals(data, dss)
    return dss
931333
def timing(self, stats, value):
        
        self.update_stats(stats, value, self.SC_TIMING)
703039
function doStat(statName, statValue, statIdentifier, cb) {
    statName = sanatizeInput(statName);
    statValue = sanatizeInput(statValue);
    statIdentifier = sanatizeInput(statIdentifier);
    var stat = statName + ":" + statValue + "|" + statIdentifier;
    sendQ.push(stat, cb);
  }