mirror of
https://github.com/furyfire/trueskill.git
synced 2025-03-19 08:18:38 +00:00
Refactoring for PHP8.2
This commit is contained in:
@ -7,7 +7,7 @@ use DNW\Skills\Tests\TestCase;
|
||||
|
||||
class BasicMathTest extends TestCase
|
||||
{
|
||||
public function testSquare()
|
||||
public function testSquare(): void
|
||||
{
|
||||
$this->assertEquals(1, BasicMath::square(1));
|
||||
$this->assertEquals(1.44, BasicMath::square(1.2));
|
||||
|
@ -10,21 +10,21 @@ class GaussianDistributionTest extends TestCase
|
||||
{
|
||||
const ERROR_TOLERANCE = 0.000001;
|
||||
|
||||
public function testCumulativeTo()
|
||||
public function testCumulativeTo(): void
|
||||
{
|
||||
// Verified with WolframAlpha
|
||||
// (e.g. http://www.wolframalpha.com/input/?i=CDF%5BNormalDistribution%5B0%2C1%5D%2C+0.5%5D )
|
||||
$this->assertEqualsWithDelta(0.691462, GaussianDistribution::cumulativeTo(0.5), GaussianDistributionTest::ERROR_TOLERANCE);
|
||||
}
|
||||
|
||||
public function testAt()
|
||||
public function testAt(): void
|
||||
{
|
||||
// Verified with WolframAlpha
|
||||
// (e.g. http://www.wolframalpha.com/input/?i=PDF%5BNormalDistribution%5B0%2C1%5D%2C+0.5%5D )
|
||||
$this->assertEqualsWithDelta(0.352065, GaussianDistribution::at(0.5), GaussianDistributionTest::ERROR_TOLERANCE);
|
||||
}
|
||||
|
||||
public function testMultiplication()
|
||||
public function testMultiplication(): void
|
||||
{
|
||||
// I verified this against the formula at http://www.tina-vision.net/tina-knoppix/tina-memo/2003-003.pdf
|
||||
$standardNormal = new GaussianDistribution(0, 1);
|
||||
@ -46,7 +46,7 @@ class GaussianDistributionTest extends TestCase
|
||||
$this->assertEqualsWithDelta($expectedSigma, $product2->getStandardDeviation(), GaussianDistributionTest::ERROR_TOLERANCE);
|
||||
}
|
||||
|
||||
public function testDivision()
|
||||
public function testDivision(): void
|
||||
{
|
||||
// Since the multiplication was worked out by hand, we use the same numbers but work backwards
|
||||
$product = new GaussianDistribution(0.2, 3.0 / sqrt(10));
|
||||
@ -63,7 +63,7 @@ class GaussianDistributionTest extends TestCase
|
||||
$this->assertEqualsWithDelta(7.0, $product2DividedByM4S5->getStandardDeviation(), GaussianDistributionTest::ERROR_TOLERANCE);
|
||||
}
|
||||
|
||||
public function testLogProductNormalization()
|
||||
public function testLogProductNormalization(): void
|
||||
{
|
||||
// Verified with Ralf Herbrich's F# implementation
|
||||
$standardNormal = new GaussianDistribution(0, 1);
|
||||
@ -76,7 +76,7 @@ class GaussianDistributionTest extends TestCase
|
||||
$this->assertEqualsWithDelta(-2.5168046699816684, $lpn2, GaussianDistributionTest::ERROR_TOLERANCE);
|
||||
}
|
||||
|
||||
public function testLogRatioNormalization()
|
||||
public function testLogRatioNormalization(): void
|
||||
{
|
||||
// Verified with Ralf Herbrich's F# implementation
|
||||
$m1s2 = new GaussianDistribution(1, 2);
|
||||
@ -85,7 +85,7 @@ class GaussianDistributionTest extends TestCase
|
||||
$this->assertEqualsWithDelta(2.6157405972171204, $lrn, GaussianDistributionTest::ERROR_TOLERANCE);
|
||||
}
|
||||
|
||||
public function testAbsoluteDifference()
|
||||
public function testAbsoluteDifference(): void
|
||||
{
|
||||
// Verified with Ralf Herbrich's F# implementation
|
||||
$standardNormal = new GaussianDistribution(0, 1);
|
||||
|
@ -9,7 +9,7 @@ use DNW\Skills\Tests\TestCase;
|
||||
|
||||
class MatrixTest extends TestCase
|
||||
{
|
||||
public function testTwoByTwoDeterminant()
|
||||
public function testTwoByTwoDeterminant(): void
|
||||
{
|
||||
$a = new SquareMatrix(1, 2,
|
||||
3, 4);
|
||||
@ -32,7 +32,7 @@ class MatrixTest extends TestCase
|
||||
$this->assertEquals(12 * 21 - 15 * 17, $d->getDeterminant());
|
||||
}
|
||||
|
||||
public function testThreeByThreeDeterminant()
|
||||
public function testThreeByThreeDeterminant(): void
|
||||
{
|
||||
$a = new SquareMatrix(1, 2, 3,
|
||||
4, 5, 6,
|
||||
@ -48,7 +48,7 @@ class MatrixTest extends TestCase
|
||||
$this->assertEquals(-90, $pi->getDeterminant());
|
||||
}
|
||||
|
||||
public function testFourByFourDeterminant()
|
||||
public function testFourByFourDeterminant(): void
|
||||
{
|
||||
$a = new SquareMatrix(1, 2, 3, 4,
|
||||
5, 6, 7, 8,
|
||||
@ -66,7 +66,7 @@ class MatrixTest extends TestCase
|
||||
$this->assertEquals(98, $pi->getDeterminant());
|
||||
}
|
||||
|
||||
public function testEightByEightDeterminant()
|
||||
public function testEightByEightDeterminant(): void
|
||||
{
|
||||
$a = new SquareMatrix(1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 10, 11, 12, 13, 14, 15, 16,
|
||||
@ -92,7 +92,7 @@ class MatrixTest extends TestCase
|
||||
$this->assertEquals(1378143, $pi->getDeterminant());
|
||||
}
|
||||
|
||||
public function testEquals()
|
||||
public function testEquals(): void
|
||||
{
|
||||
$a = new SquareMatrix(1, 2,
|
||||
3, 4);
|
||||
@ -130,7 +130,7 @@ class MatrixTest extends TestCase
|
||||
$this->assertTrue($g->equals($h));
|
||||
}
|
||||
|
||||
public function testAdjugate()
|
||||
public function testAdjugate(): void
|
||||
{
|
||||
// From Wikipedia: http://en.wikipedia.org/wiki/Adjugate_matrix
|
||||
$a = new SquareMatrix(1, 2,
|
||||
@ -152,7 +152,7 @@ class MatrixTest extends TestCase
|
||||
$this->assertTrue($d->equals($c->getAdjugate()));
|
||||
}
|
||||
|
||||
public function testInverse()
|
||||
public function testInverse(): void
|
||||
{
|
||||
// see http://www.mathwords.com/i/inverse_of_a_matrix.htm
|
||||
$a = new SquareMatrix(4, 3,
|
||||
|
Reference in New Issue
Block a user