Args:
            category: unit category

        Returns: generator over all units of a specific category in this coalition
336115
def get_units_from_category(self, category) -> typing.Iterator['BaseUnit']:
        
        Mission.validator_group_category.validate(category, 'group category')
        for unit in self.units:

            if unit.group_category == category:
                yield unit
1265284
def get_categories(self, catpath="/"):

        

        response = self._req('/browse/categorytree', {
            "catpath":catpath
        })

        categories = response['categories']

        return categories
337328
def categories(self):
    '''
    
    '''

    if not getattr(self, '_categories', False):
      self._categories = [re.sub(r'^Category:', '', x) for x in
        [link['title']
        for link in self.__continued_query({
          'prop': 'categories',
          'cllimit': 'max'
        })
      ]]

    return self._categories
282568
def __related_categories(self, category_id):
        
        related = []
        for cat in self.categories_tree:
            if category_id in self.categories_tree[cat]:
                related.append(self.categories[cat])
        return related
257784
def create_child_item_for_category(category)
      category.child_items.find_or_create_by(categorizable_type: self.categorizable.class.base_class.name, categorizable_id: self.categorizable.id, master_item_id: self.id)
    end
58437
def _repr_categories(self):
        
        max_categories = (10 if get_option("display.max_categories") == 0 else
                          get_option("display.max_categories"))
        from pandas.io.formats import format as fmt
        if len(self.categories) > max_categories:
            num = max_categories // 2
            head = fmt.format_array(self.categories[:num], None)
            tail = fmt.format_array(self.categories[-num:], None)
            category_strs = head + ["..."] + tail
        else:
            category_strs = fmt.format_array(self.categories, None)

        # Strip all leading spaces, which format_array adds for columns...
        category_strs = [x.strip() for x in category_strs]
        return category_strs
956036
def related_by_category(obj, count, collected_so_far, mods=[], only_from_same_site=True):
    
    related = []
    # top objects in given category
    if count > 0:
        from ella.core.models import Listing
        cat = obj.category
        listings = Listing.objects.get_queryset_wrapper(
            category=cat,
            content_types=[ContentType.objects.get_for_model(m) for m in mods]
        )
        for l in listings[0:count + len(related)]:
            t = l.publishable
            if t != obj and t not in collected_so_far and t not in related:
                related.append(t)
                count -= 1

            if count <= 0:
                return related
    return related
357388
def gen_category(yaml_file, sig):
    '''
    
    '''

    out_dic = yaml.load(open(yaml_file))

    for key in out_dic:

        if key.endswith('00'):
            uid = key[1:]
            cur_dic = out_dic[key]
            porder = cur_dic['order']
            cat_dic = {
                'uid': uid,
                'slug': cur_dic['slug'],
                'name': cur_dic['name'],
                'count': 0,
                'tmpl': 1,
                'pid': '0000',
                'order': porder * 100,
                'kind': '{0}'.format(sig),
            }

            MCategory.add_or_update(uid, cat_dic)
        else:
            sub_arr = out_dic[key]
            pid = key[1:3]

            for sub_dic in sub_arr:
                porder = out_dic['z' + pid + '00']['order']

                for key2 in sub_dic:
                    uid = key2[1:]

                    cur_dic = sub_dic[key2]

                    sorder = cur_dic['order']
                    cat_dic = {
                        'uid': uid,
                        'slug': cur_dic['slug'],
                        'name': cur_dic['name'],
                        'count': 0,
                        'tmpl': 1,
                        'pid': pid + '00',
                        'order': porder * 100 + sorder,
                        'kind': '{0}'.format(sig),
                    }

                    MCategory.add_or_update(pid + uid, cat_dic)
914353
def unique_categories(categories):
    """"""
    categories = np.unique(categories)
    categories = np.setdiff1d(categories, np.array(settings.categories_to_ignore))
    categories = np.array(natsorted(categories, key=lambda v: v.upper()))
    return categories
940714
def actions_for_category(category):
    
    actions = set()
    for action, action_category in _action_categories.items():
        if action_category == category:
           actions.add(action)
    return actions
359481
def title(self, category):
        
        return sum(
            [self.getWidth(category, x) for x in self.fields])
756655
def calculate_category_probability(self):
        
        total_tally = 0.0
        probs = {}
        for category, bayes_category in \
                self.categories.get_categories().items():
            count = bayes_category.get_tally()
            total_tally += count
            probs[category] = count

        # Calculating the probability
        for category, count in probs.items():
            if total_tally > 0:
                probs[category] = float(count)/float(total_tally)
            else:
                probs[category] = 0.0

        for category, probability in probs.items():
            self.probabilities[category] = {
                # Probability that any given token is of this category
                'prc': probability,
                # Probability that any given token is not of this category
                'prnc': sum(probs.values()) - probability
            }
676007
def depth(self):
        
        sub_categories = self._sub_categories
        if not sub_categories:
            return 1
        first_depth = sub_categories[0].depth
        for category in sub_categories[1:]:
            if category.depth != first_depth:
                raise ValueError('category depth not uniform')
        return first_depth + 1
297318
def set_category(self, infohash_list, category):
        
        data = self._process_infohash_list(infohash_list)
        data['category'] = category
        return self._post('command/setCategory', data=data)
814606
def get_classifications(subcategory_key):
    
    classifications = definition(subcategory_key)['classifications']
    return sorted(classifications, key=lambda k: k['key'])
829541
def Categories(unicode_dir=_UNICODE_DIR):
  

  categories = {}

  def DoLine(codes, fields):
    """Process single UnicodeData.txt line, updating categories."""
    category = fields[2]
    categories.setdefault(category, []).extend(codes)
    # Add codes from Lu into L, etc.
    if len(category) > 1:
      short = category[0]
      categories.setdefault(short, []).extend(codes)

  ReadUnicodeTable(unicode_dir+"/UnicodeData.txt", 15, DoLine)
  return categories
717733
def add_category(self, category):
        
        self._categories = self._ensure_append(category, self._categories)