:param tagnames: a list of valid tag names
        :param array: an array with the same length as the asset collection
        :returns: an array of aggregate values with the proper shape
422396
def aggregate_by(self, tagnames, array):
        
        missing = set(tagnames) - set(self.tagcol.tagnames)
        if missing:
            raise ValueError('Unknown tagname(s) %s' % missing)
        A, *shp = array.shape
        if A != len(self):
            raise ValueError('The array must have length %d, got %d' %
                             (len(self), A))
        if not tagnames:
            return array.sum(axis=0)
        shape = [len(getattr(self.tagcol, tagname))-1 for tagname in tagnames]
        acc = numpy.zeros(shape, (F32, shp) if shp else F32)
        for asset, row in zip(self.array, array):
            acc[tuple(idx - 1 for idx in asset[tagnames])] += row
        return acc
531047
public function tagWithTagIds($tag_ids = [])
    {
        if (count($tag_ids) <= 0) {
            return;
        }

		$model = static::$taggingUtility->tagModelString();
		$tag_names = $model::byTagIds($tag_ids)->lists('name')->all();

		$this->retag($tag_names);
    }
1299661
def get_model_counts(tagged_models, tag):
    
    model_counts = []
    for model in tagged_models:
        model['count'] = model['query'](tag).count()
        if model['count']:
            model_counts.append(model)
                 
    return model_counts
685822
Tag[] tags(String tagname) {
        ListBuffer<Tag> found = new ListBuffer<Tag>();
        String target = tagname;
        if (target.charAt(0) != '@') {
            target = "@" + target;
        }
        for (Tag tag : tagList) {
            if (tag.kind().equals(target)) {
                found.append(tag);
            }
        }
        return found.toArray(new Tag[found.length()]);
    }
818553
def calculate_tag_cloud(num = 5)
      range = 0

      tags = active_tags.map { |tag, posts|
        [tag.to_s, range < (size = posts.size) ? range = size : size]
      }

      range = 1..range

      tags.sort!.map! { |tag, size| [tag, range.quantile(size, num)] }
    end
626844
def pull_tag_dict(data):
    
    # If there are tags, set them to a normal dict, vs. a list of dicts:
    tags = data.pop('Tags', {}) or {}
    if tags:
        proper_tags = {}
        for tag in tags:
            proper_tags[tag['Key']] = tag['Value']

        tags = proper_tags

    return tags
1185290
def tags_from_hit(self, tag_ids):
        
        ids = []
        for t in tag_ids.split():
            t = t.strip()
            try:
                t = int(t)
            except ValueError:
                pass
            else:
                ids.append(t)

        if not ids:
            return []

        return Tag.query.filter(Tag.id.in_(ids)).all()
735473
def tag(self, *tags):
        
        if not all(isinstance(tag, collections.Hashable) for tag in tags):
            raise TypeError('Tags must be hashable')
        self.tags.update(tags)
        return self
621865
def tags(self, tags=None):
        
        if tags is None or not tags:
            return self
        nodes = []
        for node in self.nodes:
            if any(tag in node.extra['tags'] for tag in tags):
                nodes.append(node)
        self.nodes = nodes
        return self
853065
def tags(self):
        
        return dict([(t, self._catalog.tags.get(t, t)) for t in self._asset.get("tags", [])])
456015
def set_tags(self, tags):
        

        c_old_tags = []
        old_tags = []
        c_new_tags = []
        new_tags = []

        to_remove = []
        to_add = []

        tags_on_server = self.get_tags()

        for tag in tags_on_server:
            c_old_tags.append(tag.get_name().lower())
            old_tags.append(tag.get_name())

        for tag in tags:
            c_new_tags.append(tag.lower())
            new_tags.append(tag)

        for i in range(0, len(old_tags)):
            if not c_old_tags[i] in c_new_tags:
                to_remove.append(old_tags[i])

        for i in range(0, len(new_tags)):
            if not c_new_tags[i] in c_old_tags:
                to_add.append(new_tags[i])

        self.remove_tags(to_remove)
        self.add_tags(to_add)
153132
ArrayTagSet addAll(String[] ts) {
    if (ts.length % 2 != 0) {
      throw new IllegalArgumentException("array length must be even, (length=" + ts.length + ")");
    }

    if (ts.length == 0) {
      return this;
    } else {
      int tsLength = ts.length / 2;
      Tag[] newTags = new Tag[tsLength];
      for (int i = 0; i < tsLength; ++i) {
        final int j = i * 2;
        newTags[i] = new BasicTag(ts[j], ts[j + 1]);
      }
      return addAll(newTags, tsLength);
    }
  }
651221
def get_tagvalues(self, tagnames, tagidxs):
        
        values = tuple(getattr(self, tagname)[tagidx + 1]
                       for tagidx, tagname in zip(tagidxs, tagnames))
        return values
1359846
public static Collection<String> getAllTagNames(Collection<Channel> channels) {
		Collection<String> tagNames = new HashSet<String>();
		for (Channel channel : channels) {
			tagNames.addAll(getTagNames(channel));
		}
		return tagNames;
	}
771805
def tags= (tags)

      tags = tags.split(',') if tags.is_a?(String)

      @tags = TagArray.new(list_id, tags)

      queue_operation('setTasks', tags.join(','))
    end
1031661
def tags_all(self):
        
        if 'tags' not in self.database.collection_names():
            print 'Warning: Searching on non-existance tags collection'
            return None

        cursor = self.database['tags'].find({}, {'_id':0, 'md5':1, 'tags':1})
        return [item for item in cursor]
1209454
def tag_array(events):
    
    all_tags = sorted(set(tag for event in events for tag in event.tags))
    array = np.zeros((len(events), len(all_tags)))
    for row, event in enumerate(events):
        for tag in event.tags:
            array[row, all_tags.index(tag)] = 1
    return array