mirror of
https://github.com/furyfire/trueskill.git
synced 2025-03-19 08:18:38 +00:00
Coding standards.
This commit is contained in:
@ -10,6 +10,18 @@ class GaussianDistributionTest extends TestCase
|
||||
{
|
||||
private const ERROR_TOLERANCE = 0.000001;
|
||||
|
||||
public function testGetters(): void
|
||||
{
|
||||
$gd = new GaussianDistribution(10, 3);
|
||||
|
||||
$this->assertEquals(10, $gd->getMean());
|
||||
$this->assertEquals(9, $gd->getVariance());
|
||||
$this->assertEquals(3, $gd->getStandardDeviation());
|
||||
$this->assertEquals(1 / 9, $gd->getPrecision());
|
||||
$this->assertEquals(1 / 9 * 10, $gd->getPrecisionMean());
|
||||
$this->assertEqualsWithDelta(0.13298076013, $gd->getNormalizationConstant(), GaussianDistributionTest::ERROR_TOLERANCE);
|
||||
}
|
||||
|
||||
public function testCumulativeTo(): void
|
||||
{
|
||||
// Verified with WolframAlpha
|
||||
|
@ -6,6 +6,7 @@ use DNW\Skills\Numerics\IdentityMatrix;
|
||||
use DNW\Skills\Numerics\Matrix;
|
||||
use DNW\Skills\Numerics\SquareMatrix;
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
use Exception;
|
||||
|
||||
// phpcs:disable PSR2.Methods.FunctionCallSignature,Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma
|
||||
class MatrixTest extends TestCase
|
||||
@ -129,6 +130,16 @@ class MatrixTest extends TestCase
|
||||
3, 4);
|
||||
|
||||
$this->assertTrue($g->equals($h));
|
||||
|
||||
$i = new Matrix(1, 2, [[1,2]]);
|
||||
$j = new Matrix(2, 1, [[1],[2]]);
|
||||
|
||||
$this->assertFalse($i->equals($j));
|
||||
|
||||
$k = new Matrix(2, 2, [[1,2],[3,4]]);
|
||||
$l = new Matrix(2, 2, [[4,3],[2,1]]);
|
||||
|
||||
$this->assertFalse($k->equals($l));
|
||||
}
|
||||
|
||||
public function testAdjugate(): void
|
||||
@ -185,5 +196,35 @@ class MatrixTest extends TestCase
|
||||
$ccInverse = Matrix::multiply($c, $cInverse);
|
||||
$this->assertTrue($identity3x3->equals($ccInverse));
|
||||
}
|
||||
|
||||
public function testErrorDeterminant(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$matrix = new Matrix(2, 3, [[1,2,3],[1,2,3]]);
|
||||
$matrix->getDeterminant();
|
||||
}
|
||||
|
||||
public function testErrorAdjugate(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$matrix = new Matrix(2, 3, [[1,2,3],[1,2,3]]);
|
||||
$matrix->getAdjugate();
|
||||
}
|
||||
|
||||
public function testErrorAdd(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$m1 = new Matrix(2, 3, [[1,2,3],[1,2,3]]);
|
||||
$m2 = new Matrix(1, 1, [[1,1]]);
|
||||
Matrix::add($m1, $m2);
|
||||
}
|
||||
|
||||
public function testErrorMultiply(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$m1 = new Matrix(2, 3, [[1,2,3],[1,2,3]]);
|
||||
$m2 = new Matrix(1, 1, [[1,1]]);
|
||||
Matrix::multiply($m1, $m2);
|
||||
}
|
||||
}
|
||||
// phpcs:enable
|
||||
|
29
tests/Numerics/RangeTest.php
Normal file
29
tests/Numerics/RangeTest.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace DNW\Skills\Tests\Numerics;
|
||||
|
||||
use DNW\Skills\Numerics\Range;
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
use Exception;
|
||||
|
||||
class RangeTest extends TestCase
|
||||
{
|
||||
public function testConstructInvalidParam(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$range = new Range(10, 5);
|
||||
}
|
||||
|
||||
public function testFactoryInclusiveInvalidParam(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$range = Range::inclusive(10, 5);
|
||||
}
|
||||
|
||||
public function testNormalUse(): void
|
||||
{
|
||||
$range = Range::inclusive(1, 10);
|
||||
$this->assertEquals(1, $range->getMin());
|
||||
$this->assertEquals(10, $range->getMax());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user