Counts the number of times each element is used in a document
508419
def count_elements(doc):
    ""
    summary = {}
    for el in doc.iter():
        try:
            namespace, element_name = re.search('^{(.+)}(.+)$', el.tag).groups()
        except:
            namespace = None
            element_name = el.tag
        if not summary.has_key(namespace):
            summary[namespace] = {}
        if not summary[namespace].has_key(element_name):
            summary[namespace][element_name] = 1
        else:
            summary[namespace][element_name] += 1
    return summary
972376
def count_all
      # Iterate over all elements, and repeat recursively for all elements which themselves contain children.
      total_count = count
      @tags.each_value do |value|
        total_count += value.count_all if value.children?
      end
      return total_count
    end
68012
def count(self, *args, **kw):
        
        obj = args[0]
        if self.method_name in obj._memo:
            self.hit = self.hit + 1
        else:
            self.miss = self.miss + 1
266265
private static void countElements(byte[] fp, IAtomContainer mol) {
        int b;
        CountElements ce = new CountElements(mol);

        b = 0;
        if (ce.getCount("H") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 1;
        if (ce.getCount("H") >= 8) fp[b >> 3] |= MASK[b % 8];
        b = 2;
        if (ce.getCount("H") >= 16) fp[b >> 3] |= MASK[b % 8];
        b = 3;
        if (ce.getCount("H") >= 32) fp[b >> 3] |= MASK[b % 8];
        b = 4;
        if (ce.getCount("Li") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 5;
        if (ce.getCount("Li") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 6;
        if (ce.getCount("B") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 7;
        if (ce.getCount("B") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 8;
        if (ce.getCount("B") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 9;
        if (ce.getCount("C") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 10;
        if (ce.getCount("C") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 11;
        if (ce.getCount("C") >= 8) fp[b >> 3] |= MASK[b % 8];
        b = 12;
        if (ce.getCount("C") >= 16) fp[b >> 3] |= MASK[b % 8];
        b = 13;
        if (ce.getCount("C") >= 32) fp[b >> 3] |= MASK[b % 8];
        b = 14;
        if (ce.getCount("N") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 15;
        if (ce.getCount("N") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 16;
        if (ce.getCount("N") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 17;
        if (ce.getCount("N") >= 8) fp[b >> 3] |= MASK[b % 8];
        b = 18;
        if (ce.getCount("O") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 19;
        if (ce.getCount("O") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 20;
        if (ce.getCount("O") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 21;
        if (ce.getCount("O") >= 8) fp[b >> 3] |= MASK[b % 8];
        b = 22;
        if (ce.getCount("O") >= 16) fp[b >> 3] |= MASK[b % 8];
        b = 23;
        if (ce.getCount("F") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 24;
        if (ce.getCount("F") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 25;
        if (ce.getCount("F") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 26;
        if (ce.getCount("Na") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 27;
        if (ce.getCount("Na") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 28;
        if (ce.getCount("Si") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 29;
        if (ce.getCount("Si") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 30;
        if (ce.getCount("P") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 31;
        if (ce.getCount("P") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 32;
        if (ce.getCount("P") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 33;
        if (ce.getCount("S") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 34;
        if (ce.getCount("S") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 35;
        if (ce.getCount("S") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 36;
        if (ce.getCount("S") >= 8) fp[b >> 3] |= MASK[b % 8];
        b = 37;
        if (ce.getCount("Cl") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 38;
        if (ce.getCount("Cl") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 39;
        if (ce.getCount("Cl") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 40;
        if (ce.getCount("Cl") >= 8) fp[b >> 3] |= MASK[b % 8];
        b = 41;
        if (ce.getCount("K") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 42;
        if (ce.getCount("K") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 43;
        if (ce.getCount("Br") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 44;
        if (ce.getCount("Br") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 45;
        if (ce.getCount("Br") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 46;
        if (ce.getCount("I") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 47;
        if (ce.getCount("I") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 48;
        if (ce.getCount("I") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 49;
        if (ce.getCount("Be") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 50;
        if (ce.getCount("Mg") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 51;
        if (ce.getCount("Al") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 52;
        if (ce.getCount("Ca") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 53;
        if (ce.getCount("Sc") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 54;
        if (ce.getCount("Ti") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 55;
        if (ce.getCount("V") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 56;
        if (ce.getCount("Cr") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 57;
        if (ce.getCount("Mn") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 58;
        if (ce.getCount("Fe") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 59;
        if (ce.getCount("Co") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 60;
        if (ce.getCount("Ni") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 61;
        if (ce.getCount("Cu") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 62;
        if (ce.getCount("Zn") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 63;
        if (ce.getCount("Ga") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 64;
        if (ce.getCount("Ge") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 65;
        if (ce.getCount("As") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 66;
        if (ce.getCount("Se") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 67;
        if (ce.getCount("Kr") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 68;
        if (ce.getCount("Rb") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 69;
        if (ce.getCount("Sr") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 70;
        if (ce.getCount("Y") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 71;
        if (ce.getCount("Zr") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 72;
        if (ce.getCount("Nb") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 73;
        if (ce.getCount("Mo") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 74;
        if (ce.getCount("Ru") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 75;
        if (ce.getCount("Rh") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 76;
        if (ce.getCount("Pd") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 77;
        if (ce.getCount("Ag") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 78;
        if (ce.getCount("Cd") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 79;
        if (ce.getCount("In") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 80;
        if (ce.getCount("Sn") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 81;
        if (ce.getCount("Sb") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 82;
        if (ce.getCount("Te") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 83;
        if (ce.getCount("Xe") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 84;
        if (ce.getCount("Cs") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 85;
        if (ce.getCount("Ba") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 86;
        if (ce.getCount("Lu") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 87;
        if (ce.getCount("Hf") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 88;
        if (ce.getCount("Ta") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 89;
        if (ce.getCount("W") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 90;
        if (ce.getCount("Re") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 91;
        if (ce.getCount("Os") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 92;
        if (ce.getCount("Ir") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 93;
        if (ce.getCount("Pt") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 94;
        if (ce.getCount("Au") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 95;
        if (ce.getCount("Hg") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 96;
        if (ce.getCount("Tl") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 97;
        if (ce.getCount("Pb") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 98;
        if (ce.getCount("Bi") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 99;
        if (ce.getCount("La") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 100;
        if (ce.getCount("Ce") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 101;
        if (ce.getCount("Pr") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 102;
        if (ce.getCount("Nd") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 103;
        if (ce.getCount("Pm") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 104;
        if (ce.getCount("Sm") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 105;
        if (ce.getCount("Eu") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 106;
        if (ce.getCount("Gd") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 107;
        if (ce.getCount("Tb") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 108;
        if (ce.getCount("Dy") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 109;
        if (ce.getCount("Ho") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 110;
        if (ce.getCount("Er") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 111;
        if (ce.getCount("Tm") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 112;
        if (ce.getCount("Yb") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 113;
        if (ce.getCount("Tc") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 114;
        if (ce.getCount("U") >= 1) fp[b >> 3] |= MASK[b % 8];
    }
665299
def count(cls, name):
        """"""
        counter = cls.collection.find_one({'name': name}) or {}
        return counter.get('seq', 0)
352410
function processChildren( &$textElements,
                              &$children, $key, &$item, &$index, &$isFirstRun,
                              &$delimiterStructure, &$sequenceStructure, &$filterStructure,
                              $tpl, $rootNamespace, $name, $functionPlacement,
                              &$variableIterator, $noLastValue,
                              &$iteratorData )
    {
        if ( $variableIterator !== null )
        {
            unset( $last );
            if ( !$noLastValue and $iteratorData['iterator'] !== false )
            {
                $last =& $iteratorData['iterator'];
            }
            else
            {
                $last = false;
            }
            unset( $iteratorData['iterator'] );
            $iteratorData['iterator'] = new eZTemplateSectionIterator();
            $iteratorData['iterator']->setIteratorValues( $item, $key, $index, $index + 1, false, $last );
            unset( $last );

            $iteratorObject =& $iteratorData['iterator'];
            $tpl->setVariable( $variableIterator, $iteratorObject, $name );
        }
        else
        {
            $tpl->setVariable( "key", $key, $name );
            $tpl->setVariable( "item", $item, $name );
            $tpl->setVariable( "index", $index, $name );
            $tpl->setVariable( "number", $index + 1, $name );
        }
        if ( count( $filterStructure ) > 0 )
        {
            $filterCount = count( $filterStructure );
            $includeElement = true;
            for ( $i = 0; $i < $filterCount; ++$i )
            {
                $filterElement =& $filterStructure[$i];
                $filterParameters =& $filterElement[3];
                $filterName = $filterElement[2];
                $filterMatch = null;
                if ( isset( $filterParameters["match"] ) )
                {
                    $filterMatch = $tpl->elementValue( $filterParameters["match"], $rootNamespace, $name, $functionPlacement );
                    if ( $filterMatch )
                        $includeElement = $filterName == "section-exclude" ? false : true;
                }
                else
                    $tpl->missingParameter( "section:$filterName", "match" );
            }
            if ( !$includeElement )
                return false;
        }
        if ( $delimiterStructure !== null and !$isFirstRun )
        {
            $delimiterParameters = $delimiterStructure[3];
            $delimiterMatch = true;
            if ( isset( $delimiterParameters["modulo"] ) )
            {
                $delimiterModulo = $delimiterParameters["modulo"];
                $modulo = $tpl->elementValue( $delimiterModulo, $rootNamespace, $name, $functionPlacement );
                $modulo = trim( $modulo );
                if ( is_numeric( $modulo ) )
                    $delimiterMatch = ( $index % $modulo ) == 0;
            }
            if ( isset( $delimiterParameters["match"] ) )
            {
                $delimiterMatchParameter = $delimiterParameters["match"];
                $delimiterMatch = $tpl->elementValue( $delimiterMatchParameter, $rootNamespace, $name, $functionPlacement );
            }
            if ( $delimiterMatch )
            {
                $delimiterChildren =& $delimiterStructure[1];
                if ( is_array( $delimiterChildren ) )
                {
                    foreach ( array_keys( $delimiterChildren ) as $delimiterChildKey )
                    {
                        $delimiterChild =& $delimiterChildren[$delimiterChildKey];
                        $tpl->processNode( $delimiterChild, $textElements, $rootNamespace, $name );
                    }
                }
            }
        }
        $isFirstRun = false;
        if ( $sequenceStructure !== null and is_array( $sequenceStructure ) )
        {
            $sequenceValue = array_shift( $sequenceStructure );
            if ( $variableIterator !== null )
            {
                $iteratorData['iterator']->setSequence( $sequenceValue );
            }
            else
            {
                $tpl->setVariable( "sequence", $sequenceValue, $name );
            }
            $sequenceStructure[] = $sequenceValue;
        }
        foreach ( array_keys( $children ) as $childKey )
        {
            $child =& $children[$childKey];
            $tpl->processNode( $child, $textElements, $rootNamespace, $name );
        }
        ++$index;
        return true;
    }
691209
def _find_duplicates(seq):
    """"""
    seen = set()
    return [element for element in seq
            if seq.count(element) > 1
            and element not in seen and seen.add(element) is None]
193099
def count_records(self, record_counter, file):
        """"""
        counter = record_counter
        events_counter = 0
        for record in file.get_records():
            recid = record[2]
            counter[recid] = counter.get(recid, 0) + 1
            events_counter += 1

        self.stat['user_record_events'] = events_counter
        return counter
157088
def filter_repeated(self):
        '''
        
        '''
        defaults = {
            'occurrences': 1,
            'interval': 30,
            'refresh': 1800
        }

        # Override defaults with anything defined in the settings
        if isinstance(self.settings['sensu_plugin'], dict):
            defaults.update(self.settings['sensu_plugin'])

        occurrences = int(self.event['check'].get(
            'occurrences', defaults['occurrences']))
        interval = int(self.event['check'].get(
            'interval', defaults['interval']))
        refresh = int(self.event['check'].get(
            'refresh', defaults['refresh']))

        if self.event['occurrences'] < occurrences:
            self.bail('not enough occurrences')

        if (self.event['occurrences'] > occurrences and
                self.event['action'] == 'create'):
            return

        number = int(refresh / interval)
        if (number == 0 or
                (self.event['occurrences'] - occurrences) % number == 0):
            return

        self.bail('only handling every ' + str(number) + ' occurrences')
119440
function lineCount(value) {
        var rows = 0;
        if (value) {
            rows = 1;
            value.toString().each(/\n/, function () { return rows++; });
        }
        return rows;
    }
179218
def _rel_ref_count(self, rId):
        
        rIds = self._element.xpath('//@r:id')
        return len([_rId for _rId in rIds if _rId == rId])
1034821
function(element) {
		var att, count = 0,
			keys;
		this._getatts(element).forEach(function(x) {
			att = x[1];
			keys = gui.KeyMaster.extractKey(att.value);
			if (keys) {
				keys.forEach(function(key) {
					edbml.$revoke(key);
					count++;
				});
			}
		});
		return count;
	}
1149431
private Integer getNumberOfDocuments(List<File> inputFiles) throws ResourceInitializationException{
	  String directory = (String) getConfigParameterValue(PARAM_INPUTDIR);
	  String filename = directory+"/"+FILE_BASE_SEGMENTATION;
	  for (File file : inputFiles) {
		if (file.getAbsolutePath().equals(filename)){
			try {
				String line;
				BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
				while ((line = bf.readLine()) != null){
					String docName = (line.split("\t"))[0];
					if (!(filenames.contains(docName))){
						filenames.add(docName);
					}
				}
				bf.close();
			} catch (IOException e) {
				throw new ResourceInitializationException(e);
			}
		}
	  }	  
	  int  docCounter = filenames.size();
	  return docCounter;
  }
440690
public function count() {
		if(!$this->initialized)
			$this->initialize();

		return count($this->elements) - count($this->toRemove) + count($this->toAdd);
	}
1342961
def _count_values(self):
        """"""
        indices = {yi: [i] for i, yi in enumerate(self.y) if self.status[i]}

        return indices
866017
def count(self, item):
        """"""
        # pylint: disable=arguments-differ
        key, value = item
        return 1 if key in self._dict and self._dict[key] == value else 0
177484
def _get_num_of_documents(self):
        '''
        
        '''
        parser = etree.XMLParser(target=XMLElementCountTarget('document'))
        # When iterated over, 'results' will contain the output from
        # target parser's close() method
        num_of_documents = etree.parse(self.urml_file, parser)
        self._num_of_documents = num_of_documents
        return num_of_documents