Compute diplomacy.
765041
def get_diplomacy(self):
        """"""
        if not self._cache['teams']:
            self.get_teams()

        player_num = 0
        computer_num = 0
        for player in self._header.scenario.game_settings.player_info:
            if player.type == 'human':
                player_num += 1
            elif player.type == 'computer':
                computer_num += 1
        total_num = player_num + computer_num

        diplomacy = {
            'FFA': (len(self._cache['teams']) == total_num) and total_num > 2,
            'TG':  len(self._cache['teams']) == 2 and total_num > 2,
            '1v1': total_num == 2,
        }

        diplomacy['type'] = 'Other'
        team_sizes = sorted([len(team) for team in self._cache['teams']])
        diplomacy['team_size'] = 'v'.join([str(size) for size in team_sizes])
        if diplomacy['FFA']:
            diplomacy['type'] = 'FFA'
            diplomacy['team_size'] = 'FFA'
        elif diplomacy['TG']:
            diplomacy['type'] = 'TG'
        elif diplomacy['1v1']:
            diplomacy['type'] = '1v1'
        return diplomacy
134120
def _compute(self):
        """"""
        positive_vals, negative_vals = self._get_separated_values()

        if self.logarithmic:
            positive_vals = list(
                filter(lambda x: x > self.zero, positive_vals)
            )
            negative_vals = list(
                filter(lambda x: x > self.zero, negative_vals)
            )

        self._compute_box(positive_vals, negative_vals)
        positive_vals = positive_vals or [self.zero]
        negative_vals = negative_vals or [self.zero]

        self._x_pos = [
            x / self._len for x in range(self._len + 1)
        ] if self._len > 1 else [0, 1]  # Center if only one value

        self._points(self._x_pos)

        self.negative_cumulation = [0] * self._len
        self.positive_cumulation = [0] * self._len

        if self.secondary_series:
            positive_vals, negative_vals = self._get_separated_values(True)
            positive_vals = positive_vals or [self.zero]
            negative_vals = negative_vals or [self.zero]
            self.secondary_negative_cumulation = [0] * self._len
            self.secondary_positive_cumulation = [0] * self._len
            self._pre_compute_secondary(positive_vals, negative_vals)

        self._x_pos = [(i + .5) / self._len for i in range(self._len)]
1120456
def pawns_at(self, x, y):
        """"""
        for pawn in self.pawn.values():
            if pawn.collide_point(x, y):
                yield pawn
266652
private void acceptNewState( double fx_candidate ) {
		DMatrixRMaj tmp = x;
		x = x_next;
		x_next = tmp;

		fx = fx_candidate;

		mode = Mode.COMPUTE_DERIVATIVES;
	}
375536
private void computePsiSmooth(GrayF32 ux , GrayF32 uy , GrayF32 vx , GrayF32 vy ,
								  GrayF32 psiSmooth ) {
		int N = derivFlowUX.width * derivFlowUX.height;

		for( int i = 0; i < N; i++ ) {
			float vux = ux.data[i];
			float vuy = uy.data[i];
			float vvx = vx.data[i];
			float vvy = vy.data[i];

			float mu = vux*vux + vuy*vuy;
			float mv = vvx*vvx + vvy*vvy;

			psiSmooth.data[i] = (float)(1.0/(2.0*Math.sqrt(mu + mv + EPSILON*EPSILON)));
		}
	}
728130
def _compute_f5(self, C, pga_rock):
        
        return C['a10'] + C['a11'] * np.log(pga_rock + C['c5'])
42461
def compute():
    """"""
    if what == "numpy":
        y = eval(expr)
    else:
        y = ne.evaluate(expr)
    return len(y)
141349
def compute(self, x_arr, y_arr):
        '''
        
        '''
        y_arr += 1e-08
        return np.sum(x_arr * np.log(x_arr / y_arr), axis=-1)
210017
private synchronized void precomputeLogs(int len) {
    if(len <= ilogs.length) {
      return; // Probably done by another thread.
    }
    double[] logs = Arrays.copyOf(ilogs, len);
    for(int i = ilogs.length; i < len; i++) {
      logs[i] = FastMath.log1p(i);
    }
    this.ilogs = logs;
  }
975563
def run(self, gates, n_qubits, *args, **kwargs):
        """"""
        return self._run(gates, n_qubits, args, kwargs)
55106
def _compute(self):
        """"""
        if self._min:
            self._box.ymin = min(self._min, self.zero)
        if self._max:
            self._box.ymax = max(self._max, self.zero)
        self._x_pos = [
            x / self._len for x in range(self._len + 1)
        ] if self._len > 1 else [0, 1]  # Center if only one value

        self._points(self._x_pos)

        self._x_pos = [(i + .5) / self._len for i in range(self._len)]
1171105
def build_computation(self,
                          message: Message,
                          transaction: BaseOrSpoofTransaction) -> BaseComputation:
        """"""
        transaction_context = self.vm_state.get_transaction_context(transaction)
        if message.is_create:
            is_collision = self.vm_state.has_code_or_nonce(
                message.storage_address
            )

            if is_collision:
                # The address of the newly created contract has *somehow* collided
                # with an existing contract address.
                computation = self.vm_state.get_computation(message, transaction_context)
                computation._error = ContractCreationCollision(
                    "Address collision while creating contract: {0}".format(
                        encode_hex(message.storage_address),
                    )
                )
                self.vm_state.logger.debug2(
                    "Address collision while creating contract: %s",
                    encode_hex(message.storage_address),
                )
            else:
                computation = self.vm_state.get_computation(
                    message,
                    transaction_context,
                ).apply_create_message()
        else:
            computation = self.vm_state.get_computation(
                message,
                transaction_context).apply_message()

        return computation
699710
function(context) {
		if(context && typeof this._args[0] === 'function') {
			this._args[1] = context;
		} else if(context) {
			this._args[2] = context;
		}

		return new Compute(this._args[0], this._args[1], this._args[2], this._args[3]);
	}
918647
def _compute_results(self):
        
        self.Y_best = best_value(self.Y)
        self.x_opt = self.X[np.argmin(self.Y),:]
        self.fx_opt = np.min(self.Y)
167418
protected function compute (): void
    {
        $candidateCount = $this->_selfElection->countCandidates();
        $majority = $this->_selfElection->sumValidVotesWeightWithConstraints() / 2;

        $candidateDone = [];
        $result = [];
        $CandidatesWinnerCount = 0;
        $CandidatesLoserCount = 0;

        $iteration = 0;

        while (count($candidateDone) < $candidateCount) :
            $score = $this->makeScore($candidateDone);
            $maxScore = max($score);
            $minScore = min($score);

            $this->_Stats[++$iteration] = $score;

            if ( $maxScore > $majority ) :
                foreach ($score as $candidateKey => $candidateScore) :
                    if ($candidateScore !== $maxScore) :
                        continue;
                    else :
                        $candidateDone[] = $candidateKey;
                        $result[++$CandidatesWinnerCount][] = $candidateKey;
                    endif;
                endforeach;
            else :
                $LosersToRegister = [];

                foreach ($score as $candidateKey => $candidateScore) :
                    if ($candidateScore !== $minScore) :
                        continue;
                    else :
                        $LosersToRegister[] = $candidateKey;
                    endif;
                endforeach;

                // Tie Breaking
                $round = count($LosersToRegister);
                for ($i = 1 ; $i < $round ; $i++) : // A little silly. But ultimately shorter and simpler.
                    $LosersToRegister = $this->tieBreaking($LosersToRegister);
                endfor;

                $CandidatesLoserCount += count($LosersToRegister);
                $candidateDone = array_merge($candidateDone, $LosersToRegister);
                $result[$candidateCount - $CandidatesLoserCount + 1] = $LosersToRegister;
            endif;

        endwhile;

        $this->_Result = $this->createResult($result);
    }
861124
private void reconcileWith(int i, Cell cell)
    {
        cells[i] = cell.reconcile(cells[i]);
    }
1008226
protected function compute () : void
    {
        $pairwise = $this->_selfElection->getPairwise(false);
        $HeadToHead = [];

        foreach ($pairwise as $candidateId => $CandidateStats) :
            foreach ($CandidateStats['lose'] as $opponentId => $CandidateLose) :
                if (($diff = $CandidateLose - $CandidateStats['win'][$opponentId]) >= 0) :
                    $HeadToHead[$candidateId][$opponentId] = $diff;
                endif;
            endforeach;
        endforeach;

        $dodgsonQuick = [];

        foreach ($HeadToHead as $candidateId => $CandidateTidemanScores) :
            $dodgsonQuick[$candidateId] = 0;

            foreach ($CandidateTidemanScores as $opponentId => $oneTidemanScore) :
                $dodgsonQuick[$candidateId] += ceil($oneTidemanScore / 2);
            endforeach;
        endforeach;
        asort($dodgsonQuick);

        $rank = 0;
        $result = [];

        if($basicCondorcetWinner = $this->_selfElection->getWinner(null)) :
            $result[++$rank][] = $this->_selfElection->getCandidateKey($basicCondorcetWinner);
        endif;

        $lastDodgsonQuickValue = null;

        foreach ($dodgsonQuick as $CandidateId => $dodgsonQuickValue) :
            if($lastDodgsonQuickValue === $dodgsonQuickValue) :
                $result[$rank][] = $CandidateId;
            else:
                $result[++$rank][] = $CandidateId;
                $lastDodgsonQuickValue = $dodgsonQuickValue;
            endif;
        endforeach;

        $this->_Stats = $dodgsonQuick;
        $this->_Result = $this->createResult($result);
    }