Returns the top N actions by count.
18319
def get_top_n_action_types(self, top_n):
        """"""
        # Count action types
        action_type_to_counts = dict()
        for action in self.actions:
            actiontype = action.actiontype
            if actiontype not in action_type_to_counts:
                action_type_to_counts[actiontype] = 1
            else:
                action_type_to_counts[actiontype] = \
                        action_type_to_counts[actiontype] + 1

        # Convert the dictionary representation into a pair of lists
        action_types = list()
        counts = list()
        for actiontype in action_type_to_counts.keys():
            action_types.append(actiontype)
            counts.append(action_type_to_counts[actiontype])

        # How many actions in total?
        num_actions = len(self.actions)
        num_actions2 = 0
        for count in counts:
            num_actions2 = num_actions2 + count
        if num_actions != num_actions2:
            raise(Exception('Problem counting everything up!'))

        # Sort action types by count (lowest to highest)
        sorted_inds = np.argsort(counts)
        last_ind = len(sorted_inds)-1

        # Return the top N actions
        top_actions = list()
        if top_n > len(sorted_inds):
            raise Exception('Asked for top %d action types, ' +
                            'but there are only %d action types'
                            % (top_n, len(sorted_inds)))
        for i in range(top_n):
            top_actions.append(action_types[sorted_inds[last_ind-i]])
        return top_actions
567127
def get_upcoming(self, count: int) -> List[ScheduledTransaction]:
        
        # load all enabled scheduled transactions
        all_tx = self.query.filter(ScheduledTransaction.enabled == 1).all()

        # calculate next occurrence date
        for tx in all_tx:
            next_date = get_next_occurrence(tx)
            tx["next_date"] = next_date

        # order by next occurrence date
        all_tx.sort(key=lambda tx: tx["next_date"].value)
        # get upcoming (top) 10
        top_n = all_tx[:count]
        return top_n
880173
def top_n_list(lang, n, wordlist='best', ascii_only=False):
    
    results = []
    for word in iter_wordlist(lang, wordlist):
        if (not ascii_only) or max(word) <= '~':
            results.append(word)
            if len(results) >= n:
                break
    return results
1074609
def count(self):
        
        return (
            self
            .mapPartitions(lambda p: [sum(1 for _ in p)])
            .reduce(operator.add)
        )
867410
def top(self, sort_by):
        """"""
        sort = sorted(self.results, key=sort_by)
        return sort
1356770
def all_possible_productions(self) -> List[str]:
        
        all_actions = set()
        for action_set in self.get_nonterminal_productions().values():
            all_actions.update(action_set)
        return sorted(all_actions)
42951
def to_list(self):
        ''''''
        res = []
        for a in self.__class__.ACTIONS:
            aBit = self.__class__.action_bitmask(a)
            if ((self & aBit) == aBit):
                res.append(a)
        return res
2796
function() {

		var actions = this._actions,
			nActions = this._nActiveActions,
			bindings = this._bindings,
			nBindings = this._nActiveBindings;

		this._nActiveActions = 0;
		this._nActiveBindings = 0;

		for ( var i = 0; i !== nActions; ++ i ) {

			actions[ i ].reset();

		}

		for ( var i = 0; i !== nBindings; ++ i ) {

			bindings[ i ].useCount = 0;

		}

		return this;

	}
173535
def list_actions(self):
        

        actions = []
        for path, actionName, action in self:
            actions.append(self.__namespace_splitter.join(itertools.chain(path, (actionName,))))
        return sorted(actions)
284736
public RunList<R> limit(final int n) {
        return limit(new CountingPredicate<R>() {
            public boolean apply(int index, R input) {
                return index<n;
            }
        });
    }
1047571
def indexOf(self, action):
        
        for i, act in enumerate(self.actionGroup().actions()):
            if action in (act, act.objectName(), act.text()):
                return i
        return -1
1259953
def count(self, weighted=True):
        """"""
        return self._measures.weighted_n if weighted else self._measures.unweighted_n
236578
def top_broadcasts(count = 10)
      top_broadcasts = []
      request('getTopBroadcastsCombined').each do |key, _val|
        broadcast_id = key.split(':')[1]
        top_broadcasts.push(Broadcast.new(self, broadcast_id))
        count -= 1
        break if count == 0
      end

      top_broadcasts
    end
1357189
def num_events(self):
        """"""
        if not self._num_events:
            self._num_events = self.coll_handle.count()
        return self._num_events
1074281
def count(self):
        
        self.log.info("Running 'count'")
        retvals = {}

        # Numbers of 'tasks'
        num_tasks = self._count_tasks()
        retvals['num_tasks'] = num_tasks

        # Numbers of 'files'
        num_files = self._count_repo_files()
        retvals['num_files'] = num_files

        return retvals
783721
def best_actions(self):
        """"""
        if self._best_actions is None:
            best_prediction = self.best_prediction
            self._best_actions = tuple(
                action
                for action, action_set in self._action_sets.items()
                if action_set.prediction == best_prediction
            )
        return self._best_actions
795646
def _sorted_actions(self):
        
        for a in filter(lambda _: not _.last and \
                        not self.is_action(_, 'parsers'), self._actions):
            yield a
        for a in filter(lambda _: _.last and \
                        not self.is_action(_, 'parsers'), self._actions):
            yield a
        for a in filter(lambda _: self.is_action(_, 'parsers'),
                        self._actions):
            yield a