add facet counts &c
349358
function augment(el) {
  // FIXME should always have a type
  el.type = el.type || 'category';
  el.icon = (typesIcons[el.type] || typesIcons.default).icon;
  el.data = { value: el.text, type: el.type };
  // branch
  if (el.children && el.children.length > 0) {
    el.state = { opened: el.children.length > 50 ? false : true };
    el.children.forEach(function(c) {
      c = augment(c);
    });
    el.text = el.text + ' [' + el.children.length + ']';
  // value or category
  } else if (el.size && el.size > 0) {
    if (curAnnos.indexOf(el.text) > -1) {
      el.state = { selected: true };
    }
    el.text = el.text + ' (' + el.size + ')';
  }
  return el;

}
521730
def add_label_count(self):
        
        self._logger.info('Adding label count')

        def add_label_count(df):
            # For each n-gram and label pair, we need the maximum count
            # among all witnesses to each work, and then the sum of those
            # across all works.
            work_maxima = df.groupby(constants.WORK_FIELDNAME,
                                     sort=False).max()
            df.loc[:, constants.LABEL_COUNT_FIELDNAME] = work_maxima[
                constants.COUNT_FIELDNAME].sum()
            return df

        if self._matches.empty:
            self._matches[constants.LABEL_COUNT_FIELDNAME] = 0
        else:
            self._matches.loc[:, constants.LABEL_COUNT_FIELDNAME] = 0
            self._matches = self._matches.groupby(
                [constants.LABEL_FIELDNAME, constants.NGRAM_FIELDNAME],
                sort=False).apply(add_label_count)
        self._logger.info('Finished adding label count')
319271
def componentCount(self):
        
        return sum([self.columnCountForRow(x) for x in range(self.rowCount())])
914315
public StatsOptions addFacet(Field field) {

		Assert.notNull(field, "Facet field for statistics must not be 'null'.");

		state.facets.add(field);
		return this;
	}
848134
def count_features_type(features):
        
    counter={k.name: v for k, v in features.columns.to_series().groupby(features.dtypes)}
    binary=0
    if ('int64' in counter):
        binary=len(set(features.loc[:, (features<=1).all(axis=0)].columns.values) 
                & set(features.loc[:, (features>=0).all(axis=0)].columns.values) 
                & set(counter['int64']))    
    return (binary,len(counter['int64'])-binary if 'int64' in counter else 0,len(counter['float64']) if 'float64' in counter else 0)
658822
protected void addFacetPart(CmsSolrQuery query) {

        StringBuffer value = new StringBuffer();
        value.append("{!key=").append(m_config.getName());
        addFacetOptions(value);
        if (m_config.getIgnoreAllFacetFilters()
            || (!m_state.getCheckedEntries().isEmpty() && !m_config.getIsAndFacet())) {
            value.append(" ex=").append(m_config.getIgnoreTags());
        }
        value.append("}");
        value.append(m_config.getRange());
        query.add("facet.range", value.toString());
    }
872577
def tables_with_counts(self):
        """"""
        table_to_count = lambda t: self.count_rows(t)
        return zip(self.tables, map(table_to_count, self.tables))
836731
def show_count_associators(nickname, server, org_vm):
    
    d_assoc = fast_count_associators(server)

    svr_profiles_dict = {prof.path: prof for prof in server.profiles}

    headers = ('profile', 'ants', 'deps')
    rows = []

    assoc_dict = {}
    for prof_key, values in d_assoc.items():
        pn = profile_name(org_vm, svr_profiles_dict[prof_key])
        assoc_dict[pn] = (values['ant'], values['dep'])

    rows = []
    title = 'Display antecedent and dependent counts for possible ' \
        'autonomous and component profiles using fast method.\nDisplays the ' \
        'number of instances returned by\nAssociators request on profile for ' \
        'possible autonomous profiles. Algorithm is to enumerate ' \
        'ReferencedProfile and count Dependents/Antecedents with target path'
    headers = ('profile', 'Dependent\nCount', 'Antecedent\nCount')
    for pn, value in assoc_dict.items():
        rows.append((pn, value[1], value[0]))

    print_table(title, headers, rows, sort_columns=[0])

    g_rows = [(nickname, key, value[0], value[1])
              for key, value in assoc_dict.items()]
    ASSOC_PROPERTY_COUNTS.extend(g_rows)
952812
def get_available_facets(self):
        
        result = []
        for k, v in list(self.properties.items()):
            if isinstance(v, DateField):
                if not v.tokenize:
                    result.append((k, "date"))
            elif isinstance(v, NumericFieldAbstract):
                result.append((k, "numeric"))
            elif isinstance(v, StringField):
                if not v.tokenize:
                    result.append((k, "term"))
            elif isinstance(v, GeoPointField):
                if not v.tokenize:
                    result.append((k, "geo"))
            elif isinstance(v, ObjectField):
                for n, t in self.get_available_facets():
                    result.append((self.name + "." + k, t))
        return result
323422
def stats_table(self, data):
        """"""
        headers = OrderedDict()
        headers['combopairs'] = {
            'title': 'Combined pairs',
            'description': 'Num read pairs combined',
            'shared_key': 'read_count',
            'hidden': True,
            'scale': False
        }
        headers['perccombo'] = {
            'title': '% Combined',
            'description': '% read pairs combined',
            'max': 100,
            'min': 0,
            'suffix': '%',
            'scale': 'PiYG'
        }
        self.general_stats_addcols(data, headers)
506596
private FacetList calculateFacetList(AbstractDataTable table, String[] facetFields) {
        if(facetFields == null || facetFields.length == 0){
             throw new NullPointerException("Facet field list empty");
        }
        FacetList facetList = new FacetList();
        for (String facetField : facetFields) {
            Set<String> distinctColumnValues = dataTableExtensions.getDistinctColumnValues(table, schema.getColumnIndex(facetField));
            facetList.addFacetField(facetField, distinctColumnValues);
        }
        return facetList;
    }
1062164
public void addFeatures(List<Feature> features) {
		numFeatures += features.size();
		for (Feature feature : features) {
			featureListGrid.addFeature(feature);
		}
		if (sortFeatures) {
			featureListGrid.sort(sortFieldName, sortDirGWT);
		}
		
		if (exportCsvHandler instanceof ExportFeatureListToCsvHandler) {
			((ExportFeatureListToCsvHandler) exportCsvHandler).setFeatures(features);
		}
	}
960517
def _total_jxn_counts(fns):
    """"""
    df = pd.read_table(fns[0], header=None, names=COLUMN_NAMES)
    df.index = (df.chrom + ':' + df.start.astype(int).astype(str) + '-' +
                df.end.astype(int).astype(str))
    counts = df.unique_junction_reads
    for fn in fns[1:]:
        df = pd.read_table(fn, header=None, names=COLUMN_NAMES)
        df.index = (df.chrom + ':' + df.start.astype(int).astype(str) + '-' +
                    df.end.astype(int).astype(str))
        counts = counts.add(df.unique_junction_reads, fill_value=0)
    return counts
229934
def calibrate_counts(array, attributes, index):
    """"""
    offset = np.float32(attributes["corrected_counts_offsets"][index])
    scale = np.float32(attributes["corrected_counts_scales"][index])
    array = (array - offset) * scale
    return array
144171
def col_frequencies(col, weights=None, gap_chars='-.'):
    """"""
    counts = col_counts(col, weights, gap_chars)
    # Reduce to frequencies
    scale = 1.0 / sum(counts.values())
    return dict((aa, cnt * scale) for aa, cnt in counts.iteritems())
412158
def select_distinct(distinct_field=None, **kwargs):
    
    results = search_associations(rows=0,
                                  select_fields=[],
                                  facet_field_limits = {
                                      distinct_field : -1
                                  },
                                  facet_fields=[distinct_field],
                                  **kwargs
    )
    # TODO: map field
    return list(results['facet_counts'][distinct_field].keys())
118979
def expanded_counts_map(self):
        
        if self.hpx._ipix is None:
            return self.counts

        output = np.zeros(
            (self.counts.shape[0], self.hpx._maxpix), self.counts.dtype)
        for i in range(self.counts.shape[0]):
            output[i][self.hpx._ipix] = self.counts[i]
        return output