Decide on an anomaly outcome.

@param int[] $votes
@return int
555158
public function decideAnomaly(array $votes) : int
    {
        $scores = array_fill(0, 2, 0.);

        foreach ($votes as $i => $vote) {
            $scores[$vote] += $this->influences[$i];
        }

        return argmax($scores);
    }
353252
public function getResult ($method = true, array $options = []) : Result
    {
        $options = self::formatResultOptions($options);

        // Filter if tag is provided & return
        if ($options['%tagFilter']) :
            $chrono = new Timer_Chrono ($this->_timer, 'GetResult with filter');

            $filter = new self;

            foreach ($this->getCandidatesList() as $candidate) :
                $filter->addCandidate($candidate);
            endforeach;

            foreach ($this->getVotesList($options['tags'], $options['withTag']) as $vote) :
                $filter->addVote($vote);
            endforeach;

            unset($chrono);

            return $filter->getResult($method);
        endif;

            ////// Start //////

        // Prepare
        $this->prepareResult();

            //////

        $chrono = new Timer_Chrono ($this->_timer);

        if ($method === true) :
            $this->initResult(Condorcet::getDefaultMethod());
            $result = $this->_Calculator[Condorcet::getDefaultMethod()]->getResult();
        elseif ($method = Condorcet::isAuthMethod((string) $method)) :
            $this->initResult($method);
            $result = $this->_Calculator[$method]->getResult();
        else :
            throw new CondorcetException(8,$method);
        endif;

        $chrono->setRole('GetResult for '.$method);

        return $result;
    }
1015368
protected function countVote($toCount)
    {
        $value = 0;
        foreach ($this->votes as $login => $vote) {
            if ($vote === $toCount) {
                $value++;
            }
        }

        return $value;
    }
710455
public function votes($class = __CLASS__)
    {
        return $this->morphedByMany($class, config('follow.morph_prefix'), config('follow.followable_table'))
                    ->wherePivotIn('relation', [Follow::RELATION_UPVOTE, Follow::RELATION_DOWNVOTE])
                    ->withPivot('followable_type', 'relation', 'created_at');
    }
115674
protected function prepareResult () : bool
    {
        if ($this->_State > 2) :
            return false;
        elseif ($this->_State === 2) :
            $this->cleanupResult();

            // Do Pairewise
            $this->makePairwise();

            // Change state to result
            $this->_State = 3;

            // Return
            return true;
        else :
            throw new CondorcetException(6);
        endif;
    }
148726
public function addVote ($vote, $tag = null) : Vote
    {
        $this->prepareVoteInput($vote, $tag);

        // Check Max Vote Count
        if ( self::$_maxVoteNumber !== null && !$this->_ignoreStaticMaxVote && $this->countVotes() >= self::$_maxVoteNumber ) :
            throw new CondorcetException(16, self::$_maxVoteNumber);
        endif;


        // Register vote
        return $this->registerVote($vote, $tag); // Return the vote object
    }
501640
public function vote($imageOrAlbumId, $vote)
    {
        $this->validateVoteArgument($vote, ['up', 'down', 'veto']);

        return $this->post('gallery/' . $imageOrAlbumId . '/vote/' . $vote);
    }
1250661
public function deleteVotes() {
		$access = elgg_set_ignore_access(true);
		$access_status = access_get_show_hidden_status();
		access_show_hidden_entities(true);

		$river_items = new ElggBatch('elgg_get_river', array(
			'action_type' => 'vote',
			'object_guid' => $this->guid,
			'limit' => false,
			'wheres' => array("rv.view = \"river/object/poll/vote\""),
		));

		$river_items->setIncrementOffset(false);
		foreach ($river_items as $river_item) {
			$river_item->delete();
		}

		access_show_hidden_entities($access_status);
		elgg_set_ignore_access($access);

		elgg_delete_annotations(array(
			'guid' => $this->guid,
			'type' => "object",
			'subtype' => "poll",
			'annotation_name' => "vote",
		));

		$this->responses_by_choice = array();
		$this->response_count = 0;
		$this->voter_count = 0;
	}
891583
public function vote(TokenInterface $token, $object, array $attributes)
    {
        if (!$object instanceof Group && !$object instanceof GroupCollection) return VoterInterface::ACCESS_ABSTAIN;
        $groups = $object instanceof GroupCollection ? $object->getGroups(): array($object);
        $action = strtolower($attributes[0]);

        switch ($action) {
            case self::CREATE: return $this->checkCreation($token);
            case self::EDIT:   return $this->checkEdit($token, $groups);
            case self::DELETE: return $this->checkDelete($token, $groups);
            case self::VIEW:   return $this->checkView($token, $groups);
        }

        return VoterInterface::ACCESS_ABSTAIN;
    }
1016906
public function prepareModifyVote (Vote $existVote) : void
    {
        try {
            $this->prepareVoteInput($existVote);
            $this->setStateToVote();

            if ($this->_Votes->isUsingHandler()) : 
                $this->_Votes[$this->getVoteKey($existVote)] = $existVote;
            endif;
        }
        catch (\Exception $e) {
            throw $e;
        }
    }
979789
public function setStateToVote () : bool
    {
        if ( $this->_State === 1 ) :
                if (empty($this->_Candidates)) :
                    throw new CondorcetException(20);
                endif;

                $this->_State = 2;

        // If voting continues after a first set of results
        elseif ( $this->_State > 2 ) :
                $this->cleanupResult();
        endif;

        return true;
    }
155276
private function _CheckErrors($operation, $results)
	{
		if (is_soap_fault($results)) 
			throw new Exception("SOAP Fault: ".$results->faultcode."\n".$results->faultstring."\n", 4);
	}
922933
private function computeLastCallOfAnyFrom(array $methods): int
    {
        $calls = array_filter($this->callerTokens, function (array $token) use ($methods) {
            return in_array($token['token']['content'], $methods, true);
        });
        if (count($calls) > 0) {
            return (int) array_search(end($calls), $this->callerTokens, true);
        }

        return -2;
    }
899174
public static function average(array $array, int $decimals = 0)
    {
        $count = Arr::size($array);

        if ( ! $count) {
            return 0;
        }

        if ( ! is_int($decimals)) {
            $decimals = 0;
        }

        return round(array_sum($array) / $count, $decimals);
    }
750321
def get_or_create_votes(self, row, division, candidate_election):
        
        vote.Votes.objects.get_or_create(
            division=division,
            count=row["votecount"],
            pct=row["votepct"],
            winning=row["winner"],
            runoff=row["runoff"],
            candidate_election=candidate_election,
        )
434142
public function vote(Request $request)
    {
    	/* Check if user is loged in*/
    	if (!Auth::check()) {
    		return response()->json(['flag' => 0]);
    	}

    	/* Prepare data */
    	$userId = Auth::user()->id;
    	$itemId = $request->item_id;
    	$vote = $request->vote;

    	/* Get item's current like, dislike total */
    	$totalLike = TotalLike::where('item_id', $itemId)->first();

    	/* Get user's vote on this item */
		$like = Like::where(['user_id' => $userId, 'item_id' => $itemId])->first();

		/* Check if users vote on this item exists */
		if ($like != null) {
			if ($like->vote == 1) {	// if previous vote was like
				$totalLike->total_like--;	// decrease item's total like by 1
				$totalLike->total_like = $totalLike->total_like == null ? 0 : $totalLike->total_like;	// set 0 if total like is null
				if ($vote == 1) {	// if current vote is like
					$vote = 0;	// previous vote and current vote is same so discarde vote
				}
			} else if ($like->vote == -1) {	// if previous vote was dislike
				$totalLike->total_dislike--;	// decrease item's total like by 1
				$totalLike->total_dislike = $totalLike->total_dislike == null ? 0 : $totalLike->total_dislike;	// set 0 if total dislike is null
				if ($vote == -1) {	// if current vote is dislike
					$vote = 0;	// previous vote and current vote is same so discarde vote
				}
			}
		} else {
			$like = new Like;	// create new like object if previous vote not exists
		}

		/* Update vote data */
		$like->user_id = $userId;
		$like->item_id = $itemId;
		$like->vote = $vote;

		if ($vote == 1) {
			$totalLike->total_like++;	// increase total like if vote is like
		} else if ($vote == -1) {
			$totalLike->total_dislike++;	// increase total dislike if vote is dislike
		}

		$like->save();		// save like
		$totalLike->save();	//save total like,dislike

    	return response()->json(['flag' => 1, 'vote' => $vote, 'totalLike' => $totalLike->total_like, 'totalDislike' => $totalLike->total_dislike]);
    }
157672
private function determineExitCode(array $violations)
    {
        if (0 === count($violations)) {
            return 0;
        }

        $exitCode = self::EXIT_WITH_WARNINGS;
        foreach ($violations as $violation) {
            if (ViolationInterface::TYPE_ERROR === $violation->getType()) {
                $exitCode = self::EXIT_WITH_ERRORS;
                break;
            }
        }

        return $exitCode;
    }