Check if categories are set up
978941
def prepare
      options[:category] = options[:value] if options[:value] && !options[:category]
      fail "No categorizer set up for category tracker #{inspect}" unless options[:category]

      @categorizer = create_lambda(options[:category]) unless options[:multiple]

      # Initialize the categories. Use the list of category names to
      @categories = {}
      options[:all_categories].each { |cat| @categories[cat] = 0 } if options[:all_categories].is_a?(Enumerable)
    end
231245
def tally(self, category):
        
        try:
            bayes_category = self.categories.get_category(category)
        except KeyError:
            return 0

        return bayes_category.get_tally()
364403
function pickCategories() {
  var picked = [];
  var max = Math.floor(Math.random() * maxCategories);
  while(picked.length < max) {
    var category = pickCategory();
    if (picked.indexOf(category) === -1) {
      picked.push(category);
    }
  }
  return picked;
}
994662
public function setCategories($categories)
    {
        foreach ($categories as $key => $name) {
            $this->_categories[$key] = $name;
        }
    }
319169
def for_category(self, category, live_only=False):
        
        filters = {'tag': category.tag}

        if live_only:
            filters.update({'entry__live': True})

        return self.filter(**filters)
1289888
public static function has(string $category, string $setting) : bool
    {
        return isset(self::$settings[$category]) && isset(self::$settings[$category][$setting]);
    }
1272865
function(sCategory) {
        var filtersArray = this._categoryFilters;
        for(var i=0; i<filtersArray.length; i++) {
            if(sCategory == filtersArray[i]) {
                filtersArray.splice(i, 1);
                break;
            }
        }
        this._filterLogs();
        var elCheckbox = this.getCheckbox(sCategory);
        if(elCheckbox) {
            elCheckbox.checked = false;
        }
    }
1116102
private function categories()
    {
        $package = Package::where('name', 'Core')->first();
        $core = ConfigCategory::create([
            'key' => 'core',
            'package_id' => $package->id
        ]);
        ConfigCategory::create([
            'key' => 'core_mail',
            'parent_id' => $core->id,
            'package_id' => $core->package_id
        ]);
        ConfigCategory::create([
            'key' => 'core_general',
            'parent_id' => $core->id,
            'package_id' => $core->package_id
        ]);
        $this->general();
        $this->mail();
    }
717733
def add_category(self, category):
        
        self._categories = self._ensure_append(category, self._categories)
1061213
public function hasCategory()
    {
        $postType = getPostType($this->getTable());
        return ($postType->hasCategories && isset($this->categories) && !$this->categories->isEmpty());
    }
136764
def get_service_categories(self, restricted=True):
        
        bsc = api.get_tool("bika_setup_catalog")
        query = {
            "portal_type": "AnalysisCategory",
            "is_active": True,
            "sort_on": "sortable_title",
        }
        categories = bsc(query)
        client = self.get_client()
        if client and restricted:
            restricted_categories = client.getRestrictedCategories()
            restricted_category_ids = map(
                lambda c: c.getId(), restricted_categories)
            # keep correct order of categories
            if restricted_category_ids:
                categories = filter(
                    lambda c: c.getId in restricted_category_ids, categories)
        return categories
810405
def _set_categories(self):
        
        for column, _ in self._categories.items():
            if column in self.columns:
                self[column] = self[column].astype('category')
1346873
def _categorize(self, slug, category):
        
        key = self._category_key(category)
        self.r.sadd(key, slug)

        # Store all category names in a Redis set, for easy retrieval
        self.r.sadd(self._categories_key, category)
322580
def check_data(labels, data, args):
    """"""
    len_categories = len(data[0])

    # Check that there are data for all labels.
    if len(labels) != len(data):
        print(">> Error: Label and data array sizes don't match")
        sys.exit(1)

    # Check that there are data for all categories per label.
    for dat in data:
        if len(dat) != len_categories:
            print(">> Error: There are missing values")
            sys.exit(1)

    colors = []

    # If user inserts colors, they should be as many as the categories.
    if args['color'] is not None:
        if len(args['color']) != len_categories:
            print(">> Error: Color and category array sizes don't match")
            sys.exit(1)

        for color in args['color']:
            colors.append(AVAILABLE_COLORS.get(color))

    # Vertical graph for multiple series of same scale is not supported yet.
    if args['vertical'] and len_categories > 1 and not args['different_scale']:
        print(">> Error: Vertical graph for multiple series of same "
              "scale is not supported yet.")
        sys.exit(1)

    # If user hasn't inserted colors, pick the first n colors
    # from the dict (n = number of categories).
    if args['stacked'] and not colors:
        colors = [v for v in list(AVAILABLE_COLORS.values())[:len_categories]]

    return colors
16522
def enable_category(self, category: str) -> None:
        
        for cmd_name in list(self.disabled_commands):
            func = self.disabled_commands[cmd_name].command_function
            if hasattr(func, HELP_CATEGORY) and getattr(func, HELP_CATEGORY) == category:
                self.enable_command(cmd_name)
142461
def validate_categories_equal_entities(categories, entities, message=None,
                                       exception=MatrixError):
    """"""
    nb_categories = len(categories)
    nb_entities = len(entities)
    if message is None:
        message = 'Number of categories: %s != number of entities: %s' % (
            nb_categories, nb_entities)
    if categories and nb_categories != nb_entities:
        raise exception(message)
1143885
function categoryExist($title){
        if(self::where('title',$title)->where('model_type',$this->modelType)->first())
            return true;

        return false;
    }