fix tests

This commit is contained in:
Dennis Eichhorn 2023-10-22 20:55:05 +00:00
parent cd36282b4f
commit 95eb37853e
3 changed files with 10 additions and 8 deletions

View File

@ -714,10 +714,10 @@ class Matrix implements \ArrayAccess, \Iterator
$value2 = $B->toArray();
$m1 = \count($value1);
$n1 = ($isMatrix1 = \is_array($value1[0])) ? \count($value1[0]) : 1;
$n1 = ($isMatrix1 = !($this instanceof Vector)) ? \count($value1[0]) : 1;
$m2 = \count($value2);
$n2 = ($isMatrix2 = \is_array($value2[0])) ? \count($value2[0]) : 1;
$n2 = ($isMatrix2 = !($B instanceof Vector)) ? \count($value2[0]) : 1;
$result = null;
@ -908,6 +908,8 @@ class Matrix implements \ArrayAccess, \Iterator
/**
* Calculate e^M
*
* The algorithm uses a taylor series.
*
* @param int $iterations Iterations for approximation
*
* @return self

View File

@ -315,7 +315,7 @@ final class ImageUtils
//$color1 = \imagecolorat($src1, $i, $j);
$color2 = \imagecolorat($src2, $i, $j);
if (\abs($color1Avg - $color2Avg) / $color1Avg > 0.05 && $color1Avg > 0 && $color2Avg > 0) {
if ($color1Avg > 0 && \abs($color1Avg - $color2Avg) / $color1Avg > 0.05 && $color2Avg > 0) {
++$difference;
if ($diff === 0) {

View File

@ -498,8 +498,8 @@ final class MatrixTest extends \PHPUnit\Framework\TestCase
$v1 = Vector::fromArray([1, 3, -5])->transpose();
self::assertEquals(
3,
$v1->dot(Vector::fromArray([4, -2, -1]))
[[3]],
$v1->dot(Vector::fromArray([4, -2, -1]))->toArray()
);
}
@ -580,7 +580,7 @@ final class MatrixTest extends \PHPUnit\Framework\TestCase
self::assertEquals(
[12, 15, 18],
$m->sum(0)
$m->sum(0)->toVectorArray()
);
}
@ -594,7 +594,7 @@ final class MatrixTest extends \PHPUnit\Framework\TestCase
self::assertEquals(
[6, 15, 24],
$m->sum(1)
$m->sum(1)->toVectorArray()
);
}
@ -614,7 +614,7 @@ final class MatrixTest extends \PHPUnit\Framework\TestCase
[0, 0, -8],
]);
self::assertFalse($m->isDiagonal());
self::assertTrue($m->isDiagonal());
}
public function testPow() : void