Restores a statistics from the given flat members tree.
    :func:`make_frozen_stats_tree` makes a tree for this function.
559806
def frozen_stats_from_tree(tree):
    
    if not tree:
        raise ValueError('Empty tree')
    stats_index = []
    for parent_offset, members in tree:
        stats = FrozenStatistics(*members)
        stats_index.append(stats)
        if parent_offset is not None:
            stats_index[parent_offset].children.append(stats)
    return stats_index[0]
1284810
def as_tree(self):
        ""
        if self._nodes is None:
            return [self]
        ret = [self]
        for node in self._nodes:
            ret.append(node.as_tree())
        return ret
795326
def convert2pstats(stats):
    
    if not isinstance(stats, YFuncStats):
        raise YappiError("Source stats must be derived from YFuncStats.")
    
    import pstats
    class _PStatHolder:
        def __init__(self, d):
            self.stats = d
        def create_stats(self):
            pass                
    def pstat_id(fs):
        return (fs.module, fs.lineno, fs.name)
    
    _pdict = {}
    
    # convert callees to callers
    _callers = {}
    for fs in stats:
        if not fs in _callers:
            _callers[fs] = {}
            
        for ct in fs.children:
            if not ct in _callers:
                _callers[ct] = {}
            _callers[ct][pstat_id(fs)] = (ct.ncall, ct.nactualcall, ct.tsub ,ct.ttot)
    
    # populate the pstat dict.
    for fs in stats:
        _pdict[pstat_id(fs)] = (fs.ncall, fs.nactualcall, fs.tsub, fs.ttot, _callers[fs], )        
     
    return pstats.Stats(_PStatHolder(_pdict))
218163
def flatten_dir_tree(self, tree):
        

        result = {}

        def helper(tree, leading_path = ''):
            dirs  = tree['dirs']; files = tree['files']
            for name, file_info in files.iteritems():
                file_info['path'] = leading_path + '/'  + name
                result[file_info['path']] = file_info

            for name, contents in dirs.iteritems():
                helper(contents, leading_path +'/'+ name)
        helper(tree); return result
328043
def node_stats(self, nodes=None):
        
        parts = ["_cluster", "nodes", "stats"]
        if nodes:
            parts = ["_cluster", "nodes", ",".join(nodes), "stats"]

        path = make_path(*parts)
        return self.conn._send_request('GET', path)
866327
def statistic_record(self, desc=True, timeout=3, is_async=False, only_read=True, *keys):
        
        if len(keys) == 0:
            records = self._generate_statistic_records()
        else:
            records = self._generate_statistic_records_by_keys(keys)
        return sorted(records, key=lambda t: t['hit_counts'], reverse=desc)
1268175
def handle_stats(name, obj):
    
    return {'total_deletions': obj.total['deletions'],
            'total_insertions': obj.total['insertions'],
            'total_lines': obj.total['lines'],
            'total_files': obj.total['files'],
            'changes': obj.files}
590984
def stat_sorted_tree(dir, &block)
      return to_enum(__method__, dir) unless block_given?

      self.stat_directory(dir).sort_by { |path, stat|
        stat.directory? ? "#{path}/" : path
      }.each do |path, stat|
        yield path, stat

        if stat.directory?
          stat_sorted_tree(path, &block)
        end
      end

      nil
    end
247854
def reset(self):
        
        super(ContourTree, self).reset()
        self.edges = []
        self.augmentedEdges = {}
        self.sortedNodes = []
        self.branches = set()
        self.superNodes = []
        self.superArcs = []
924105
protected void rebuildTree() {
    final int dim = root.getDimensionality();
    double t = estimateThreshold(root) / leaves;
    t *= t;
    // Never decrease the threshold.
    thresholdsq = t > thresholdsq ? t : thresholdsq;
    LOG.debug("New squared threshold: " + thresholdsq);

    LeafIterator iter = new LeafIterator(root); // Will keep the old root.
    assert (iter.valid());
    ClusteringFeature first = iter.get();

    leaves = 0;
    // Make a new root node:
    root = new TreeNode(dim, capacity);
    root.children[0] = first;
    root.addToStatistics(first);
    ++leaves;
    for(iter.advance(); iter.valid(); iter.advance()) {
      TreeNode other = insert(root, iter.get());
      // Handle root overflow:
      if(other != null) {
        TreeNode newnode = new TreeNode(dim, capacity);
        newnode.addToStatistics(newnode.children[0] = root);
        newnode.addToStatistics(newnode.children[1] = other);
        root = newnode;
      }
    }
  }
1238518
def rebuild_nested_interval_tree!
      # temporary changes
      skip_callback :update, :before, :update_nested_interval
      old_default_scopes = default_scopes # save to revert later
      default_scope ->{ where("#{quoted_table_name}.lftq > 0") } # use lft1 > 0 as a "migrated?" flag
          
      # zero all intervals
      update_hash = {lftp: 0, lftq: 0}
      update_hash[:rgtp] = 0 if columns_hash["rgtp"]
      update_hash[:rgtq] = 0 if columns_hash["rgtq"]
      update_hash[:lft]  = 0 if columns_hash["lft"]
      update_hash[:rgt]  = 0 if columns_hash["rgt"]
      update_all update_hash
          
      # recompute intervals with a recursive lambda
      clear_cache!
      update_subtree = ->(node){
        node.create_nested_interval
        node.save
        node.class.unscoped.where(nested_interval.foreign_key => node.id).find_each &update_subtree
      }
      unscoped.roots.find_each &update_subtree

      # revert changes
      set_callback :update, :before, :update_nested_interval
      self.default_scopes = old_default_scopes
    end
779029
def on_close(self, stats, previous_stats):
        
        reports = {
            'messages': self._messages,
            'stats': stats,
            'previous': previous_stats,
        }
        print(json.dumps(reports, cls=JSONSetEncoder, indent=4), file=self.out)
917812
def stats_list(self, list=None, date=None, headers=None):
        
        data = {'stat': 'list'}
        if list is not None:
            data['list'] = list
        if date is not None:
            data['date'] = date
        return self._stats(data, headers)
570863
def statistics(self):
        
        result = {}
        for r in self.results:
            result.setdefault(r.status, 0)
            result[r.status] += 1
        return result
463956
def _flatten_subclass_tree(cls):
    
    subclasses = frozenset(cls.__subclasses__())
    children = frozenset(toolz.concat(map(_flatten_subclass_tree, subclasses)))
    return frozenset({cls}) | subclasses | children
886678
void resetStatistics(boolean clearHistory) {
        lastTimerPop = System.currentTimeMillis();
        previousCompleted = threadPool == null ? 0 : threadPool.getCompletedTaskCount();
        previousThroughput = 0;

        consecutiveQueueEmptyCount = 0;
        consecutiveNoAdjustment = 0;
        consecutiveOutlierAfterAdjustment = 0;

        consecutiveIdleCount = 0;

        if (clearHistory) {
            threadStats = new TreeMap<Integer, ThroughputDistribution>();
        }

        lastAction = LastAction.NONE;
    }
594195
def reset(self):
        '''
        
        '''
        self.resetRNG()
        sNow = np.zeros(self.pop_size)
        Shk  = self.RNG.rand(self.pop_size)
        sNow[Shk < self.p_init] = 1
        self.sNow = sNow