forked from jorgecasas/php-ml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Optimizer tests and remove initialTheta (#252)
* Add Optimizer tests * Remove Optimizer.initialTheta and rename Optimizer.setInitialTheta to setTheta
- Loading branch information
1 parent
55749c7
commit a40c50b
Showing
4 changed files
with
38 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?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]); | ||
|
||
$theta = $this->getObjectAttribute($optimizer, 'theta'); | ||
|
||
$this->assertSame($object, $optimizer); | ||
$this->assertSame([0.3, 1], $theta); | ||
} | ||
} |