2018-03-04 22:44:22 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Phpml\Tests\Helper\Optimizer;
|
|
|
|
|
|
|
|
use Phpml\Exception\InvalidArgumentException;
|
|
|
|
use Phpml\Helper\Optimizer\Optimizer;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class OptimizerTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testThrowExceptionWithInvalidTheta(): void
|
|
|
|
{
|
|
|
|
$this->expectException(InvalidArgumentException::class);
|
|
|
|
$this->expectExceptionMessage('Number of values in the weights array should be 3');
|
|
|
|
/** @var Optimizer $optimizer */
|
|
|
|
$optimizer = $this->getMockForAbstractClass(Optimizer::class, [3]);
|
|
|
|
|
|
|
|
$optimizer->setTheta([]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetTheta(): void
|
|
|
|
{
|
|
|
|
/** @var Optimizer $optimizer */
|
|
|
|
$optimizer = $this->getMockForAbstractClass(Optimizer::class, [2]);
|
|
|
|
$object = $optimizer->setTheta([0.3, 1]);
|
|
|
|
|
2018-10-28 07:44:52 +01:00
|
|
|
self::assertSame($object, $optimizer);
|
2019-04-12 07:49:30 +02:00
|
|
|
self::assertSame([0.3, 1], $object->theta());
|
2018-03-04 22:44:22 +01:00
|
|
|
}
|
|
|
|
}
|