fix tests

This commit is contained in:
Dennis Eichhorn 2024-04-24 20:34:29 +00:00
parent 5230892673
commit 126fca5574
9 changed files with 34 additions and 26 deletions

View File

@ -188,7 +188,7 @@ final class AffinityPropagation implements ClusteringInterface
/** /**
* Find the nearest group for a point * Find the nearest group for a point
* *
* @param array<int, array<int, int|float>> $similarityMatrix Similarity matrix * @param array<int, Point> $similarityMatrix Similarity matrix
* @param int $point Point id in the similarity matrix to compare * @param int $point Point id in the similarity matrix to compare
* *
* @return int * @return int

View File

@ -42,7 +42,7 @@ final class AgglomerativeClustering implements ClusteringInterface
* @var \Closure * @var \Closure
* @since 1.0.0 * @since 1.0.0
*/ */
private \Closure $metric; public \Closure $metric;
/** /**
* Metric to calculate the distance between two points * Metric to calculate the distance between two points
@ -50,7 +50,7 @@ final class AgglomerativeClustering implements ClusteringInterface
* @var \Closure * @var \Closure
* @since 1.0.0 * @since 1.0.0
*/ */
private \Closure $linkage; public \Closure $linkage;
/** /**
* Constructor * Constructor

View File

@ -89,7 +89,7 @@ class Point implements PointInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function isEquals(PointInterface $point) : bool public function isEquals(Point $point) : bool
{ {
return $this->name === $point->name && $this->coordinates === $point->coordinates; return $this->name === $point->name && $this->coordinates === $point->coordinates;
} }

View File

@ -67,11 +67,11 @@ interface PointInterface
/** /**
* Check if two points are equal * Check if two points are equal
* *
* @param self $point Point to compare with * @param Point $point Point to compare with
* *
* @return bool * @return bool
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function isEquals(self $point) : bool; public function isEquals(Point $point) : bool;
} }

View File

@ -139,8 +139,8 @@ final class Loan
* *
* @param float $loan Loan amount * @param float $loan Loan amount
* @param float $r Rate * @param float $r Rate
* @param float $duration Loan duration * @param int $duration Loan duration
* @param float $interval Payment interval * @param int $interval Payment interval
* *
* @return float * @return float
* *
@ -156,7 +156,7 @@ final class Loan
* *
* @param float $loan Loan amount * @param float $loan Loan amount
* @param float $r Rate * @param float $r Rate
* @param float $interval Payment interval * @param int $interval Payment interval
* *
* @return float * @return float
* *
@ -171,7 +171,7 @@ final class Loan
* Calculate the principal for amortization loans * Calculate the principal for amortization loans
* *
* @param float $payment Total payment * @param float $payment Total payment
* @param float $interval Payment interval * @param float $interest Interest payment
* *
* @return float * @return float
* *
@ -183,6 +183,8 @@ final class Loan
} }
/** /**
* Calculate schedule for amortization loan
*
* @param float $loan Loan amount * @param float $loan Loan amount
* @param float $r Borrowing rate (annual) * @param float $r Borrowing rate (annual)
* @param int $duration Loan duration in months * @param int $duration Loan duration in months

View File

@ -217,6 +217,9 @@ abstract class CodeAbstract
public function saveToPngFile(string $file) : void public function saveToPngFile(string $file) : void
{ {
$res = $this->get(); $res = $this->get();
if ($res === null) {
return;
}
\imagepng($res, $file); \imagepng($res, $file);
\imagedestroy($res); \imagedestroy($res);
@ -234,6 +237,9 @@ abstract class CodeAbstract
public function saveToJpgFile(string $file) : void public function saveToJpgFile(string $file) : void
{ {
$res = $this->get(); $res = $this->get();
if ($res === null) {
return;
}
\imagejpeg($res, $file); \imagejpeg($res, $file);
\imagedestroy($res); \imagedestroy($res);