From 126fca55746007e6ae6235b8fdea6cf585bad2ce Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 24 Apr 2024 20:34:29 +0000 Subject: [PATCH] fix tests --- Algorithm/Clustering/AffinityPropagation.php | 6 +++--- Algorithm/Clustering/AgglomerativeClustering.php | 4 ++-- Algorithm/Clustering/DBSCAN.php | 14 +++++++------- Algorithm/Clustering/Kmeans.php | 8 ++++---- Algorithm/Clustering/MeanShift.php | 6 +++--- Algorithm/Clustering/Point.php | 2 +- Algorithm/Clustering/PointInterface.php | 4 ++-- Business/Finance/Loan.php | 10 ++++++---- Utils/Barcode/CodeAbstract.php | 6 ++++++ 9 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Algorithm/Clustering/AffinityPropagation.php b/Algorithm/Clustering/AffinityPropagation.php index ca601e98a..ea7b04a87 100644 --- a/Algorithm/Clustering/AffinityPropagation.php +++ b/Algorithm/Clustering/AffinityPropagation.php @@ -104,7 +104,7 @@ final class AffinityPropagation implements ClusteringInterface * Generate clusters for points * * @param Point[] $points Points to cluster - * @param int $iterations Iterations for cluster generation + * @param int $iterations Iterations for cluster generation * * @return void * @@ -188,8 +188,8 @@ final class AffinityPropagation implements ClusteringInterface /** * Find the nearest group for a point * - * @param array> $similarityMatrix Similarity matrix - * @param int $point Point id in the similarity matrix to compare + * @param array $similarityMatrix Similarity matrix + * @param int $point Point id in the similarity matrix to compare * * @return int * diff --git a/Algorithm/Clustering/AgglomerativeClustering.php b/Algorithm/Clustering/AgglomerativeClustering.php index 3ace0ffaf..b65901773 100644 --- a/Algorithm/Clustering/AgglomerativeClustering.php +++ b/Algorithm/Clustering/AgglomerativeClustering.php @@ -42,7 +42,7 @@ final class AgglomerativeClustering implements ClusteringInterface * @var \Closure * @since 1.0.0 */ - private \Closure $metric; + public \Closure $metric; /** * Metric to calculate the distance between two points @@ -50,7 +50,7 @@ final class AgglomerativeClustering implements ClusteringInterface * @var \Closure * @since 1.0.0 */ - private \Closure $linkage; + public \Closure $linkage; /** * Constructor diff --git a/Algorithm/Clustering/DBSCAN.php b/Algorithm/Clustering/DBSCAN.php index dd94bca41..921db2fd9 100644 --- a/Algorithm/Clustering/DBSCAN.php +++ b/Algorithm/Clustering/DBSCAN.php @@ -130,10 +130,10 @@ final class DBSCAN implements ClusteringInterface * Expand cluster with additional point and potential neighbors. * * @param Point $point Point to add to a cluster - * @param array $neighbors Neighbors of point - * @param int $c Cluster id - * @param float $epsilon Max distance - * @param int $minPoints Min amount of points required for a cluster + * @param array $neighbors Neighbors of point + * @param int $c Cluster id + * @param float $epsilon Max distance + * @param int $minPoints Min amount of points required for a cluster * * @return void * @@ -175,7 +175,7 @@ final class DBSCAN implements ClusteringInterface * Find neighbors of a point * * @param Point $point Base point for potential neighbors - * @param float $epsilon Max distance to neighbor + * @param float $epsilon Max distance to neighbor * * @return array * @@ -252,8 +252,8 @@ final class DBSCAN implements ClusteringInterface * Generate the clusters of the points * * @param Point[] $points Points to cluster - * @param float $epsilon Max distance - * @param int $minPoints Min amount of points required for a cluster + * @param float $epsilon Max distance + * @param int $minPoints Min amount of points required for a cluster * * @return void * diff --git a/Algorithm/Clustering/Kmeans.php b/Algorithm/Clustering/Kmeans.php index 902896b76..139fe3aca 100755 --- a/Algorithm/Clustering/Kmeans.php +++ b/Algorithm/Clustering/Kmeans.php @@ -121,8 +121,8 @@ final class Kmeans implements ClusteringInterface /** * Generate the clusters of the points * - * @param Point[] $points Points to cluster - * @param int<1, max> $clusters Amount of clusters + * @param Point[] $points Points to cluster + * @param int<1, max> $clusters Amount of clusters * * @return void * @@ -210,8 +210,8 @@ final class Kmeans implements ClusteringInterface /** * Initialize cluster centers * - * @param Point[] $points Points to use for the cluster center initialization - * @param int<0, max> $n Amount of clusters to use + * @param Point[] $points Points to use for the cluster center initialization + * @param int<0, max> $n Amount of clusters to use * * @return Point[] * diff --git a/Algorithm/Clustering/MeanShift.php b/Algorithm/Clustering/MeanShift.php index d753bb10e..4ccde9c1d 100644 --- a/Algorithm/Clustering/MeanShift.php +++ b/Algorithm/Clustering/MeanShift.php @@ -119,7 +119,7 @@ final class MeanShift implements ClusteringInterface /** * Generate the clusters of the points * - * @param Point[] $points Points to cluster + * @param Point[] $points Points to cluster * @param array $bandwidth Bandwidth(s) * * @return void @@ -170,8 +170,8 @@ final class MeanShift implements ClusteringInterface /** * Perform shift on a point * - * @param Point $point Point to shift - * @param Point $points Array of all points + * @param Point $point Point to shift + * @param Point $points Array of all points * @param array $bandwidth Bandwidth(s) * * @return Point diff --git a/Algorithm/Clustering/Point.php b/Algorithm/Clustering/Point.php index be2293fb9..e33e54c90 100755 --- a/Algorithm/Clustering/Point.php +++ b/Algorithm/Clustering/Point.php @@ -89,7 +89,7 @@ class Point implements PointInterface /** * {@inheritdoc} */ - public function isEquals(PointInterface $point) : bool + public function isEquals(Point $point) : bool { return $this->name === $point->name && $this->coordinates === $point->coordinates; } diff --git a/Algorithm/Clustering/PointInterface.php b/Algorithm/Clustering/PointInterface.php index 3d89389be..4e84f88a8 100755 --- a/Algorithm/Clustering/PointInterface.php +++ b/Algorithm/Clustering/PointInterface.php @@ -67,11 +67,11 @@ interface PointInterface /** * Check if two points are equal * - * @param self $point Point to compare with + * @param Point $point Point to compare with * * @return bool * * @since 1.0.0 */ - public function isEquals(self $point) : bool; + public function isEquals(Point $point) : bool; } diff --git a/Business/Finance/Loan.php b/Business/Finance/Loan.php index 459a1848c..bcf13e2f8 100755 --- a/Business/Finance/Loan.php +++ b/Business/Finance/Loan.php @@ -139,8 +139,8 @@ final class Loan * * @param float $loan Loan amount * @param float $r Rate - * @param float $duration Loan duration - * @param float $interval Payment interval + * @param int $duration Loan duration + * @param int $interval Payment interval * * @return float * @@ -156,7 +156,7 @@ final class Loan * * @param float $loan Loan amount * @param float $r Rate - * @param float $interval Payment interval + * @param int $interval Payment interval * * @return float * @@ -171,7 +171,7 @@ final class Loan * Calculate the principal for amortization loans * * @param float $payment Total payment - * @param float $interval Payment interval + * @param float $interest Interest payment * * @return float * @@ -183,6 +183,8 @@ final class Loan } /** + * Calculate schedule for amortization loan + * * @param float $loan Loan amount * @param float $r Borrowing rate (annual) * @param int $duration Loan duration in months diff --git a/Utils/Barcode/CodeAbstract.php b/Utils/Barcode/CodeAbstract.php index 2782b6753..4a2ff6e0a 100755 --- a/Utils/Barcode/CodeAbstract.php +++ b/Utils/Barcode/CodeAbstract.php @@ -217,6 +217,9 @@ abstract class CodeAbstract public function saveToPngFile(string $file) : void { $res = $this->get(); + if ($res === null) { + return; + } \imagepng($res, $file); \imagedestroy($res); @@ -234,6 +237,9 @@ abstract class CodeAbstract public function saveToJpgFile(string $file) : void { $res = $this->get(); + if ($res === null) { + return; + } \imagejpeg($res, $file); \imagedestroy($res);