mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
Rector: codeQuality
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("vendor/autoload.php");
|
require_once(__DIR__ . "/vendor/autoload.php");
|
||||||
|
|
||||||
use DNW\Skills\TrueSkill\FactorGraphTrueSkillCalculator;
|
use DNW\Skills\TrueSkill\FactorGraphTrueSkillCalculator;
|
||||||
use DNW\Skills\GameInfo;
|
use DNW\Skills\GameInfo;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("vendor/autoload.php");
|
require_once(__DIR__ . "/vendor/autoload.php");
|
||||||
|
|
||||||
use DNW\Skills\TrueSkill\TwoPlayerTrueSkillCalculator;
|
use DNW\Skills\TrueSkill\TwoPlayerTrueSkillCalculator;
|
||||||
use DNW\Skills\GameInfo;
|
use DNW\Skills\GameInfo;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
|
use Rector\CodeQuality\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector;
|
||||||
|
|
||||||
return RectorConfig::configure()
|
return RectorConfig::configure()
|
||||||
->withPaths([
|
->withPaths([
|
||||||
@ -14,4 +14,7 @@ return RectorConfig::configure()
|
|||||||
])
|
])
|
||||||
// uncomment to reach your current PHP version
|
// uncomment to reach your current PHP version
|
||||||
->withPhpSets()
|
->withPhpSets()
|
||||||
->withPreparedSets(deadCode: true, codeQuality: true, typeDeclarations : true);
|
->withPreparedSets(deadCode: true, codeQuality: true, typeDeclarations : true)
|
||||||
|
->withSkip([
|
||||||
|
LocallyCalledStaticMethodToNonStaticRector::class,
|
||||||
|
]);;
|
||||||
|
@ -88,7 +88,7 @@ class Matrix
|
|||||||
|
|
||||||
private function isSquare(): bool
|
private function isSquare(): bool
|
||||||
{
|
{
|
||||||
return ($this->rowCount == $this->columnCount) && ($this->rowCount > 0);
|
return ($this->rowCount === $this->columnCount) && ($this->rowCount > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDeterminant(): float
|
public function getDeterminant(): float
|
||||||
@ -208,7 +208,7 @@ class Matrix
|
|||||||
|
|
||||||
public static function add(Matrix $left, Matrix $right): Matrix
|
public static function add(Matrix $left, Matrix $right): Matrix
|
||||||
{
|
{
|
||||||
if (($left->getRowCount() != $right->getRowCount()) || ($left->getColumnCount() != $right->getColumnCount())) {
|
if (($left->getRowCount() !== $right->getRowCount()) || ($left->getColumnCount() !== $right->getColumnCount())) {
|
||||||
throw new Exception('Matrices must be of the same size');
|
throw new Exception('Matrices must be of the same size');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ class Matrix
|
|||||||
// Just your standard matrix multiplication.
|
// Just your standard matrix multiplication.
|
||||||
// See http://en.wikipedia.org/wiki/Matrix_multiplication for details
|
// See http://en.wikipedia.org/wiki/Matrix_multiplication for details
|
||||||
|
|
||||||
if ($left->getColumnCount() != $right->getRowCount()) {
|
if ($left->getColumnCount() !== $right->getRowCount()) {
|
||||||
throw new Exception('The width of the left matrix must match the height of the right matrix');
|
throw new Exception('The width of the left matrix must match the height of the right matrix');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ class Matrix
|
|||||||
|
|
||||||
public function equals(Matrix $otherMatrix): bool
|
public function equals(Matrix $otherMatrix): bool
|
||||||
{
|
{
|
||||||
if (($this->rowCount != $otherMatrix->getRowCount()) || ($this->columnCount != $otherMatrix->getColumnCount())) {
|
if (($this->rowCount !== $otherMatrix->getRowCount()) || ($this->columnCount !== $otherMatrix->getColumnCount())) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,9 +131,11 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
|||||||
$messages = $this->getMessages();
|
$messages = $this->getMessages();
|
||||||
|
|
||||||
$result = 0.0;
|
$result = 0.0;
|
||||||
|
// We start at 1 since offset 0 has the sum
|
||||||
|
$counter = count($vars);
|
||||||
|
|
||||||
// We start at 1 since offset 0 has the sum
|
// We start at 1 since offset 0 has the sum
|
||||||
for ($i = 1; $i < count($vars); $i++) {
|
for ($i = 1; $i < $counter; $i++) {
|
||||||
$result += GaussianDistribution::logRatioNormalization($vars[$i]->getValue(), $messages[$i]->getValue());
|
$result += GaussianDistribution::logRatioNormalization($vars[$i]->getValue(), $messages[$i]->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,11 +213,15 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
|||||||
$updatedVariables = [];
|
$updatedVariables = [];
|
||||||
|
|
||||||
$indicesToUse = $this->variableIndexOrdersForWeights[$messageIndex];
|
$indicesToUse = $this->variableIndexOrdersForWeights[$messageIndex];
|
||||||
|
// The tricky part here is that we have to put the messages and variables in the same
|
||||||
|
// order as the weights. Thankfully, the weights and messages share the same index numbers,
|
||||||
|
// so we just need to make sure they're consistent
|
||||||
|
$counter = count($allMessages);
|
||||||
|
|
||||||
// The tricky part here is that we have to put the messages and variables in the same
|
// The tricky part here is that we have to put the messages and variables in the same
|
||||||
// order as the weights. Thankfully, the weights and messages share the same index numbers,
|
// order as the weights. Thankfully, the weights and messages share the same index numbers,
|
||||||
// so we just need to make sure they're consistent
|
// so we just need to make sure they're consistent
|
||||||
for ($i = 0; $i < count($allMessages); $i++) {
|
for ($i = 0; $i < $counter; $i++) {
|
||||||
$updatedMessages[] = $allMessages[$indicesToUse[$i]];
|
$updatedMessages[] = $allMessages[$indicesToUse[$i]];
|
||||||
$updatedVariables[] = $allVariables[$indicesToUse[$i]];
|
$updatedVariables[] = $allVariables[$indicesToUse[$i]];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user