Counts instances of an object that group by a certain criterion. Pass
        either a string attribute to count by, or a function that returns the
        criterion.
340446
def countBy(self, val):
        

        def by(result, key, value):
            if key not in result:
                result[key] = 0
            result[key] += 1

        res = self._group(self.obj, val, by)

        return self._wrap(res)
665299
def count(cls, name):
        """"""
        counter = cls.collection.find_one({'name': name}) or {}
        return counter.get('seq', 0)
376929
def group_by(self, *args):
        
        for name in args:
            assert name in self._fields or name in self._calculated_fields, \
                   'Cannot group by `%s` since it is not included in the query' % name
        qs = copy(self)
        qs._grouping_fields = args
        return qs
269659
def parse_instance_count(instance_count, speaker_total_count):
    

    # Use all the instances of a speaker unless specified
    result = copy.copy(speaker_total_count)
    for speaker_id, count in instance_count.items():
        speaker_id = str(speaker_id)
        speaker_total = speaker_total_count.get(speaker_id, 0)

        if type(count) == float and 0.0 <= count <= 1.0:
            result[speaker_id] = int(speaker_total * count)

        else:
            result[speaker_id] = int(count)

    return result
261586
private int countNumberOfAggregates(Frame fr, int numberOfColumns, AstRoot asts[]) {
    int validGroupByCols = 0;
    for (int idx=3; idx < asts.length; idx+=3) {  // initial loop to count operations on valid columns, ignore String columns
      AstNumList col = check(numberOfColumns, asts[idx + 1]);
      if (col.cnt() != 1) throw new IllegalArgumentException("Group-By functions take only a single column");
      int agg_col = (int) col.min(); // Aggregate column
      if (fr.vec(agg_col).isString()) {
        Log.warn("Column "+fr._names[agg_col]+" is a string column.  Groupby operations will be skipped for this column.");
      } else
        validGroupByCols++;
    }
    return validGroupByCols;
  }
1330210
def _count_elements(mapping, iterable):
    ''
    mapping_get = mapping.get
    for elem in iterable:
        mapping[elem] = mapping_get(elem, 0) + 1
1074609
def count(self):
        
        return (
            self
            .mapPartitions(lambda p: [sum(1 for _ in p)])
            .reduce(operator.add)
        )
76255
def sort_by_attr!(objects, order = { locale: :asc, key: :asc })
      order_keys = order.keys
      objects.sort! do |a, b|
        by = order_keys.detect { |k| a[k] != b[k] }
        order[by] == :desc ? b[by] <=> a[by] : a[by] <=> b[by]
      end
      objects
    end
391265
def _count_counters(self, counter):
        
        if getattr(self, 'as_set', False):
            return len(set(counter))
        else:
            return sum(counter.values())
1052791
def count(self):
        
        ids, _, ngroups = self.grouper.group_info
        val = self.obj.get_values()

        mask = (ids != -1) & ~isna(val)
        ids = ensure_platform_int(ids)
        minlength = ngroups or 0
        out = np.bincount(ids[mask], minlength=minlength)

        return Series(out,
                      index=self.grouper.result_index,
                      name=self._selection_name,
                      dtype='int64')
856162
def count(self, val):
        """"""
        _maxes = self._maxes

        if not _maxes:
            return 0

        key = self._key(val)
        pos = bisect_left(_maxes, key)

        if pos == len(_maxes):
            return 0

        _lists = self._lists
        _keys = self._keys
        idx = bisect_left(_keys[pos], key)
        total = 0
        len_keys = len(_keys)
        len_sublist = len(_keys[pos])

        while True:
            if _keys[pos][idx] != key:
                return total
            if _lists[pos][idx] == val:
                total += 1
            idx += 1
            if idx == len_sublist:
                pos += 1
                if pos == len_keys:
                    return total
                len_sublist = len(_keys[pos])
                idx = 0
959046
def __criteria(self, obj, matches=None, mt=None, lt=None, eq=None):
        '''
        
        '''
        # Fail matcher if "less than"
        for field, value in (mt or {}).items():
            if getattr(obj, field) <= value:
                return False

        # Fail matcher if "more than"
        for field, value in (lt or {}).items():
            if getattr(obj, field) >= value:
                return False

        # Fail matcher if "not equal"
        for field, value in (eq or {}).items():
            if getattr(obj, field) != value:
                return False

        # Fail matcher if "doesn't match"
        for field, value in (matches or {}).items():
            if not re.search(value, str(getattr(obj, field))):
                return False

        return True
651620
function sortByIdentifiersCount(a, b) {
  if (a.count === b.count) {
    return stringCompare(a.value, b.value)
  }

  return b.count - a.count
}
1022324
def count(self, *criterion, **kwargs):
        
        query = self._query(*criterion)
        query = self._filter(query, **kwargs)
        return query.count()
691231
function count(predicate) {
  predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate;

  let c = 0;

  for (let item of this) {
    if (predicate(item)) c++;
  }

  return c;
}
546610
def count(self, value):
        """"""
        from pcapkit.protocols.protocol import Protocol
        try:
            flag = issubclass(value, Protocol)
        except TypeError:
            flag = issubclass(type(value), Protocol)
        if flag or isinstance(value, Protocol):
            value = value.__index__()
            if isinstance(value, tuple):
                value = r'|'.join(value)

        with contextlib.suppress(Exception):
            return sum(1 for data in self.__data__ if re.fullmatch(value, data, re.IGNORECASE) is not None)
        return 0
95988
def count(self):
        
        return functools.reduce(lambda x, y: x * y, (x.count for x in self.bounds))