Calculates vote total as total_upvotes - total_downvotes. We are adding a method here instead of relying on django-secretballot's addition since that doesn't work for subclasses.
424937
def vote_total(self):
        
        modelbase_obj = self.modelbase_obj
        return modelbase_obj.votes.filter(vote=+1).count() - modelbase_obj.votes.filter(vote=-1).count()
135331
private double computeStabilityIndex(){
    	
    	int m = (int)Math.floor((this.ensemble.length-MAXPERMANENT)/2);
    	int[][] votes=new int[m][tau_size];
    	double errors=0;
    	int count=0;
   
    	
    	Pair[] arr = getHalf(true);
    	
    	for (int i=0;i<m;i++){
    		for (int j=0;j<tau_size;j++){
    			votes[i][j]=Utils.maxIndex(this.ensemble[arr[i].index].getVotesForInstance(recentChunk.get(j)));
    			errors+=(votes[i][j]==(int) this.recentChunk.get(j).classValue())?0:1;
    			count++;
    		}
    	}
    	errors = errors/count;

    	double res=0;  count=0;
    	for (int i=0;i<m;i++)
        	for (int j=i+1;j<m;j++)
        		if (i!=j){
        			res+=computeKappa(votes[i],votes[j]);
        			count++;	
        		}

    	return res/count-errors;
    }
940154
def upvotes(self, option):
    
    params = join_params(self.parameters, {"upvotes": option})

    return self.__class__(**params)
267679
def sum_to_balance(self):
        
        result = self.values("amount_currency").annotate(total=models.Sum("amount"))
        return Balance([Money(r["total"], r["amount_currency"]) for r in result])
309177
def get_percent(self):
        """"""
        if not (self.votes and self.score):
            return 0
        return 100 * (self.get_rating() / self.field.range)
144578
def top2_reduced(votes):
    
    res = np.zeros(12)
    for vote in votes:
        # the top ranked alternative is in vote[0][0], second in vote[1][0]
        if vote[0][0] == 0: # i.e. the first alt is ranked first
            res[0] += 1
            if vote[1][0] == 2:
                res[4] += 1
            elif vote[1][0] == 3:
                res[5] += 1
        elif vote[0][0] == 1:
            res[1] += 1
            if vote[1][0] == 0:
                res[6] += 1
            elif vote[1][0] == 3:
                res[7] += 1
        elif vote[0][0] == 2:
            res[2] += 1
            if vote[1][0] == 0:
                res[8] += 1
            elif vote[1][0] == 1:
                res[9] += 1
        elif vote[0][0] == 3:
            res[3] += 1
            if vote[1][0] == 1:
                res[10] += 1
            elif vote[1][0] == 2:
                res[11] += 1
    res /= len(votes)
    return res
662578
def upvote(self):
        
        data = self.get_selected_item()
        if 'likes' not in data:
            self.term.flash()
        elif getattr(data['object'], 'archived'):
            self.term.show_notification("Voting disabled for archived post", style='Error')
        elif data['likes']:
            with self.term.loader('Clearing vote'):
                data['object'].clear_vote()
            if not self.term.loader.exception:
                data['likes'] = None
        else:
            with self.term.loader('Voting'):
                data['object'].upvote()
            if not self.term.loader.exception:
                data['likes'] = True
723778
def votes(self, req) -> int:
        
        try:
            votes = len(self[req.key].propagates)
        except KeyError:
            votes = 0
        return votes
164569
def get_addition_score(source_counts, prediction_counts, target_counts):
  """"""
  added_to_prediction_counts = prediction_counts - source_counts
  true_positives = sum((added_to_prediction_counts & target_counts).values())
  selected = sum(added_to_prediction_counts.values())
  # Note that in the paper the summation is done over all the ngrams in the
  # output rather than the ngrams in the following set difference. Since the
  # former does not make as much sense we compute the latter, which is also done
  # in the GitHub implementation.
  relevant = sum((target_counts - source_counts).values())
  return _get_fbeta_score(true_positives, selected, relevant)
1225705
def basic_stats(self):
        """"""
        comment_score = sum(comment.score for comment in self.comments)
        if self.comments:
            comment_duration = (self.comments[-1].created_utc -
                                self.comments[0].created_utc)
            comment_rate = self._rate(len(self.comments), comment_duration)
        else:
            comment_rate = 0

        submission_duration = self.max_date - self.min_date
        submission_rate = self._rate(len(self.submissions),
                                     submission_duration)
        submission_score = sum(sub.score for sub in self.submissions.values())

        values = [('Total', len(self.submissions), len(self.comments)),
                  ('Rate (per day)', '{:.2f}'.format(submission_rate),
                   '{:.2f}'.format(comment_rate)),
                  ('Unique Redditors', len(self.submitters),
                   len(self.commenters)),
                  ('Combined Score', submission_score, comment_score)]

        retval = 'Period: {:.2f} days\n\n'.format(submission_duration / 86400.)
        retval += '||Submissions|Comments|\n:-:|--:|--:\n'
        for quad in values:
            retval += '__{}__|{}|{}\n'.format(*quad)
        return retval + '\n'
417548
public Vote getVotes(Instance instance) {
		ErrorWeightedVote errorWeightedVote=newErrorWeightedVote();
		//DoubleVector combinedVote = new DoubleVector();
		debug("Test",3);    
		int numberOfRulesCovering = 0;

		VerboseToConsole(instance); // Verbose to console Dataset name.
		for (Rule rule : ruleSet) {
			if (rule.isCovering(instance) == true){
				numberOfRulesCovering++;
				//DoubleVector vote = new DoubleVector(rule.getPrediction(instance));
				double [] vote=rule.getPrediction(instance);
				double error= rule.getCurrentError();
				debug("Rule No"+ rule.getRuleNumberID() + " Vote: " + Arrays.toString(vote) + " Error: " + error + " Y: " + instance.classValue(),3); //predictionValueForThisRule);
				errorWeightedVote.addVote(vote,error);
				//combinedVote.addValues(vote);
				if (!this.unorderedRulesOption.isSet()) { // Ordered Rules Option.
					break; // Only one rule cover the instance.
				}
			}
		}

		if (numberOfRulesCovering == 0) {
			//combinedVote = new DoubleVector(defaultRule.getPrediction(instance));
			double [] vote=defaultRule.getPrediction(instance);
			double error= defaultRule.getCurrentError();
			errorWeightedVote.addVote(vote,error);
			
			debug("Default Rule Vote " + Arrays.toString(vote) + " Error " + error + "  Y: " + instance.classValue(),3);
		} 	
		double[] weightedVote=errorWeightedVote.computeWeightedVote();
		double weightedError=errorWeightedVote.getWeightedError();
		
		debug("Weighted Rule - Vote: " + Arrays.toString(weightedVote) + " Weighted Error: " + weightedError + " Y:" + instance.classValue(),3);
		return new Vote(weightedVote, weightedError);
	}
1087039
def total_count(self, total_count):
        
        if total_count is None:
            raise ValueError("Invalid value for `total_count`, must not be `None`")
        if total_count is not None and total_count < 0:
            raise ValueError("Invalid value for `total_count`, must be a value greater than or equal to `0`")

        self._total_count = total_count
218596
public function calculate_totals() {

		/**
		 * @var $wpdb wpdb
		 */
		global $wpdb;

		// Set totals.
		if ( false !== $this->total_sql ) {
			$total = @current( $wpdb->get_col( $this->get_sql( $this->total_sql ) ) );
		} else {
			$total = @current( $wpdb->get_col( 'SELECT FOUND_ROWS()' ) );
		}

		$total                        = self::do_hook( 'select_total', $total, $this );
		$this->total_found            = 0;
		$this->total_found_calculated = true;

		if ( is_numeric( $total ) ) {
			$this->total_found = $total;
		}
	}
1188181
def get_income_total(self) -> Decimal:
        
        accounts = self.get_income_accounts()
        # log(DEBUG, "income accounts: %s", accounts)
        income = Decimal(0)
        for acct in accounts:
            income += acct.get_balance()
        return income
38612
def downvote
      security_transgression_unless @comment.can_be_voted_on_by?(@user) &&\
        @comment.thread.config.comment_voting.to_sym == :ld

      @comment.downvote_from @user

      respond_to do |format|
        format.html { redirect_to @thread }
        format.js { render :vote }
      end
    end
1319910
def _ratio(self, key):
        ''''''
        total = float(self._total_votes())
        try:
            return math.floor(self[key] / total * 100)
        except ZeroDivisionError:
            return float(0)
1078809
def total(self):
        
        url = "/stats/total"
        result = self._get(url)
        return StatModel.parse(result)