Returns the total number of votes cast for this
        poll options.
962673
def vote_count(self):
        
        return Vote.objects.filter(
            content_type=ContentType.objects.get_for_model(self),
            object_id=self.id
        ).aggregate(Sum('vote'))['vote__sum'] or 0
1368946
public static <X> List<X> mostVotedFor(Map<X, Double> votes) {
        // Choose the label with the greatest number of votes
        // If there is a tie, choose the one with the least index
        double maxTalley = Double.NEGATIVE_INFINITY;
        List<X> maxTickets = new ArrayList<X>();
        for(Entry<X,Double> entry : votes.entrySet()) {
            X ticket = entry.getKey();
            double talley = entry.getValue();
            if (talley > maxTalley) {
                maxTickets = new ArrayList<X>();
                maxTickets.add(ticket);
                maxTalley = talley;
            } else if (talley == maxTalley) {
                maxTickets.add(ticket);
            }
        }
        return maxTickets;
    }
321073
def get_real_rating(self):
        """"""
        if not (self.votes and self.score):
            return 0
        return float(self.score)/self.votes
1217325
public int getNumWeights() {
    if (weights == null) return 0;
    int numWeights = 0;
    for (double[] wts : weights) {
      numWeights += wts.length;
    }
    return numWeights;
  }
1343638
def results_with_percent(self):
        

        percents = [int(float(v) / sum(self.votes) * 100) if sum(self.votes) > 0 else 0 for v in self.votes]
        return zip(self.options, self.votes, percents)
648900
def count(self):
        
        actions = self._actionGroup.actions()
        if len(actions) == 1 and actions[0].objectName() == 'place_holder':
            return 0
        
        return len(actions)
355624
def elect(self, candidate_aggregates, candidate_id):
        

        # somewhat paranoid cross-check, but we've had this bug before..
        assert(candidate_id not in self.candidates_elected)

        elected_no = len(self.candidates_elected) + 1
        self.candidates_elected[candidate_id] = True

        transfer_value = 0
        excess_votes = paper_count = None
        if len(self.candidates_elected) != self.vacancies:
            excess_votes = max(candidate_aggregates.get_vote_count(candidate_id) - self.quota, 0)
            assert(excess_votes >= 0)
            paper_count = self.candidate_bundle_transactions.get_paper_count(candidate_id)
            if paper_count > 0:
                transfer_value = fractions.Fraction(excess_votes, paper_count)
            assert(transfer_value >= 0)
            self.election_distributions_pending.append((candidate_id, transfer_value, excess_votes))
        self.results.candidate_elected(
            CandidateElected(
                candidate_id=candidate_id,
                order=elected_no,
                excess_votes=excess_votes,
                paper_count=paper_count,
                transfer_value=transfer_value))
309177
def get_percent(self):
        """"""
        if not (self.votes and self.score):
            return 0
        return 100 * (self.get_rating() / self.field.range)
533507
def vote(self, identifier, weight=100.0):
        ''' 
        '''
        for num_of_retries in range(default.max_retry):
            try:
                self.steem_instance().vote(identifier, 
                    weight, self.mainaccount)
                self.msg.message("voted for " + identifier)
                time.sleep(5)
            except Exception as e:
                if re.search(r'You have already voted in a similar way', str(e)):
                    self.msg.error_message('''Already voted on 
                                        {}'''.format(identifier))
                    return "already voted"
                else:
                    self.util.retry('''COULD NOT VOTE ON 
                                    {}'''.format(identifier), 
                                    e, num_of_retries, default.wait_time)
                    self.s = None
            else:
                return True
5047
public int numberOfUpdates() {
        final Integer cachedValue = numberOfUpdatesCache;

        if (cachedValue != null) {
            return cachedValue;
        }

        int numberOfUpdates = 0;

        for (T object : results.keySet()) {
            final PutResult putResult = results.get(object);

            if (putResult.wasUpdated()) {
                //noinspection ConstantConditions
                numberOfUpdates += putResult.numberOfRowsUpdated();
            }
        }

        numberOfUpdatesCache = numberOfUpdates;

        return numberOfUpdates;
    }
1280232
public int getTotalValidWaitingOperationCount() {
        int count = 0;
        for (WaitSet waitSet : waitSetMap.values()) {
            count += waitSet.totalValidWaitingOperationCount();
        }
        return count;
    }
541975
public function voters()
    {
        $property = property_exists($this, 'vote') ? $this->vote : __CLASS__;

        return $this->morphToMany($property, 'votable', $this->vote_table ?: 'votes');
    }
649919
def top3_full(votes):
    
    #create array of zeros, length = q
    res = np.zeros(2 * len(votes[0]) + (len(votes[0]) * (len(votes[0]) - 1)))

    #iterate through each vote
    for vote in votes:
        #set verification boolean to true
        ver = True
        #check if vote belongs to c1 < c2 < c3, c2 < c3 < c1... moment
        for i in range(0, len(votes[0])):
            if vote[i][0] != vote[i - 1][0] + 1 and vote[i][0] != 0:
                ver = False
                break
        if ver:
            res[len(votes[0]) + (len(votes[0]) * (len(votes[0]) - 1)) + vote[0][0]] += 1

        #increment moment of top ranked choice ranked at the top
        res[vote[0][0]] += 1

        #top two moment
        add = 0
        if vote[0][0] > vote[1][0]:
            add = 1
        res[(vote[0][0] + 1) * (len(votes[0]) - 1) + add + vote[1][0]] += 1

    res /= len(votes) #normalize moments
    
    return res
151905
def poll(self):
        
        task = self.task

        # total job count
        n_jobs = len(self.submission_data)

        # store the number of consecutive polling failures and get the maximum number of polls
        n_poll_fails = 0
        if task.walltime == NO_FLOAT:
            max_polls = sys.maxsize
        else:
            max_polls = int(math.ceil((task.walltime * 3600.) / (task.poll_interval * 60.)))

        # update variable attributes for polling
        self.poll_data.n_finished_min = task.acceptance * (1 if task.acceptance > 1 else n_jobs)
        self.poll_data.n_failed_max = task.tolerance * (1 if task.tolerance > 1 else n_jobs)

        # track finished and failed jobs in dicts holding status data
        finished_jobs = OrderedDict()
        failed_jobs = OrderedDict()

        # start the poll loop
        for i in six.moves.range(max_polls):
            # sleep after the first iteration
            if i > 0:
                time.sleep(task.poll_interval * 60)

            # determine the currently active jobs, i.e., the jobs whose states should be checked
            active_jobs = OrderedDict()
            for job_num, data in six.iteritems(self.submission_data.jobs):
                if job_num in finished_jobs or job_num in failed_jobs:
                    continue
                if self.skip_jobs.get(job_num):
                    finished_jobs[job_num] = self.status_data_cls.job_data(
                        status=self.job_manager.FINISHED, code=0)
                else:
                    data = data.copy()
                    if not data["job_id"]:
                        data["job_id"] = self.status_data_cls.dummy_job_id
                    active_jobs[job_num] = data
            self.poll_data.n_active = len(active_jobs)

            # query job states
            job_ids = [data["job_id"] for data in six.itervalues(active_jobs)]  # noqa: F812
            _states, errors = self.job_manager.query_batch(job_ids)
            if errors:
                print("{} error(s) occured during job status query of task {}:".format(
                    len(errors), task.task_id))
                tmpl = "    {}"
                for i, err in enumerate(errors):
                    print(tmpl.format(err))
                    if i + 1 >= self.show_errors:
                        remaining = len(errors) - self.show_errors
                        if remaining > 0:
                            print("    ... and {} more".format(remaining))
                        break

                n_poll_fails += 1
                if task.poll_fails > 0 and n_poll_fails > task.poll_fails:
                    raise Exception("poll_fails exceeded")
                else:
                    continue
            else:
                n_poll_fails = 0

            # states stores job_id's as keys, so replace them by using job_num's
            states = OrderedDict()
            for job_num, data in six.iteritems(active_jobs):
                states[job_num] = self.status_data_cls.job_data(**_states[data["job_id"]])

            # store jobs per status and take further actions depending on the status
            pending_jobs = OrderedDict()
            running_jobs = OrderedDict()
            newly_failed_jobs = OrderedDict()
            retry_jobs = OrderedDict()
            for job_num, data in six.iteritems(states):
                if data["status"] == self.job_manager.PENDING:
                    pending_jobs[job_num] = data
                    task.forward_dashboard_event(self.dashboard, data, "status.pending", job_num)

                elif data["status"] == self.job_manager.RUNNING:
                    running_jobs[job_num] = data
                    task.forward_dashboard_event(self.dashboard, data, "status.running", job_num)

                elif data["status"] == self.job_manager.FINISHED:
                    finished_jobs[job_num] = data
                    self.poll_data.n_active -= 1
                    task.forward_dashboard_event(self.dashboard, data, "status.finished", job_num)

                elif data["status"] in (self.job_manager.FAILED, self.job_manager.RETRY):
                    newly_failed_jobs[job_num] = data
                    self.poll_data.n_active -= 1

                    # retry or ultimately failed?
                    if self.job_retries[job_num] < task.retries:
                        self.job_retries[job_num] += 1
                        self.submission_data.attempts[job_num] += 1
                        data["status"] = self.job_manager.RETRY
                        retry_jobs[job_num] = self.submission_data.jobs[job_num]["branches"]
                        task.forward_dashboard_event(self.dashboard, data, "status.retry", job_num)
                    else:
                        failed_jobs[job_num] = data
                        task.forward_dashboard_event(self.dashboard, data, "status.failed", job_num)

                else:
                    raise Exception("unknown job status '{}'".format(data["status"]))

            # gather some counts
            n_pending = len(pending_jobs)
            n_running = len(running_jobs)
            n_finished = len(finished_jobs)
            n_retry = len(retry_jobs)
            n_failed = len(failed_jobs)
            n_unsubmitted = len(self.submission_data.unsubmitted_jobs)

            # log the status line
            counts = (n_pending, n_running, n_finished, n_retry, n_failed)
            if task.parallel_jobs > 0:
                counts = (n_unsubmitted,) + counts
            status_line = self.job_manager.status_line(counts, last_counts=True, sum_counts=n_jobs,
                color=True, align=task.align_status_line)
            task.publish_message(status_line)
            self.last_status_counts = counts

            # inform the scheduler about the progress
            task.publish_progress(100. * n_finished / n_jobs)

            # log newly failed jobs
            if newly_failed_jobs:
                print("{} failed job(s) in task {}:".format(len(newly_failed_jobs), task.task_id))
                tmpl = "    job: {}, branches: {}, id: {job_id}, status: {status}, code: {code}, " \
                    "error: {error}"
                for i, (job_num, data) in enumerate(six.iteritems(newly_failed_jobs)):
                    branches = self.submission_data.jobs[job_num]["branches"]
                    print(tmpl.format(job_num, ",".join(str(b) for b in branches), **data))
                    if i + 1 >= self.show_errors:
                        remaining = len(newly_failed_jobs) - self.show_errors
                        if remaining > 0:
                            print("    ... and {} more".format(remaining))
                        break

            # infer the overall status
            reached_end = n_jobs == n_finished + n_failed
            finished = n_finished >= self.poll_data.n_finished_min
            failed = n_failed > self.poll_data.n_failed_max
            unreachable = n_jobs - n_failed < self.poll_data.n_finished_min
            if finished:
                # write status output
                if "status" in self._outputs:
                    status_data = self.status_data_cls()
                    status_data.jobs.update(finished_jobs)
                    status_data.jobs.update(states)
                    self._outputs["status"].dump(status_data, formatter="json", indent=4)
                break
            elif failed:
                failed_nums = [job_num for job_num in failed_jobs if job_num not in retry_jobs]
                raise Exception("tolerance exceeded for jobs {}".format(failed_nums))
            elif unreachable:
                err = None
                if reached_end:
                    err = "acceptance of {} not reached, total jobs: {}, failed jobs: {}"
                elif task.check_unreachable_acceptance:
                    err = "acceptance of {} unreachable, total jobs: {}, failed jobs: {}"
                if err:
                    raise Exception(err.format(self.poll_data.n_finished_min, n_jobs, n_failed))

            # configurable poll callback
            task.poll_callback(self.poll_data)

            # trigger automatic resubmission and submission of unsubmitted jobs
            self.submit(retry_jobs)

            # break when no polling is desired
            # we can get to this point when there was already a submission and the no_poll
            # parameter was set so that only failed jobs are resubmitted once
            if task.no_poll:
                break
        else:
            # walltime exceeded
            raise Exception("walltime exceeded")
1080163
public int count() {
        int n = 0;
        for (ConcurrentMap<?, ?> bag : registry.values()) {
            n += bag.size();
        }
        return n;
    }
693843
def get_election_votes(self, election):
        """"""
        candidate_election = CandidateElection.objects.get(
            candidate=self, election=election
        )

        return candidate_election.votes.all()
540549
private int countPivots(Type.Field[] pivots) {
		int count = 0;
		for(int i=0;i!=pivots.length;++i) {
			if(pivots[i] != null) {
				count = count + 1;
			}
		}
		return count;
	}