mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-05-24 02:08:40 +00:00
fix tests
This commit is contained in:
parent
b4af5e237c
commit
9b71428f88
|
|
@ -70,8 +70,8 @@ final class Apriori
|
||||||
*
|
*
|
||||||
* The algorithm cheks how often a set exists in a given set of sets.
|
* The algorithm cheks how often a set exists in a given set of sets.
|
||||||
*
|
*
|
||||||
* @param array<array> $sets Sets of a set (e.g. [[1,2,3,4], [1,2], [1]])
|
* @param array<string[]> $sets Sets of a set (e.g. [[1,2,3,4], [1,2], [1]])
|
||||||
* @param array $subset Subset to check for (empty array -> all subsets are checked)
|
* @param string[] $subset Subset to check for (empty array -> all subsets are checked)
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -189,11 +189,9 @@ final class MemoryCF
|
||||||
$anglePointer = \array_keys($cosine);
|
$anglePointer = \array_keys($cosine);
|
||||||
|
|
||||||
// Inspect items of the top n comparable users
|
// Inspect items of the top n comparable users
|
||||||
for ($i = 1; $i <= $size; ++$i) {
|
for ($i = 0; $i < $size; ++$i) {
|
||||||
$index = (int) ($i / 2) - 1;
|
$uId = $i % 2 === 0 ? $distancePointer[$i] : $anglePointer[$i];
|
||||||
|
$distances = $i % 2 === 0 ? $euclidean : $cosine;
|
||||||
$uId = $i % 2 === 1 ? $distancePointer[$index] : $anglePointer[$index];
|
|
||||||
$distances = $i % 2 === 1 ? $euclidean : $cosine;
|
|
||||||
|
|
||||||
foreach ($this->rankings[$uId] as $iId => $_) {
|
foreach ($this->rankings[$uId] as $iId => $_) {
|
||||||
// Item is not already in dataset and not in historic dataset (we are only interested in new)
|
// Item is not already in dataset and not in historic dataset (we are only interested in new)
|
||||||
|
|
|
||||||
|
|
@ -54,14 +54,30 @@ final class AprioriTest extends \PHPUnit\Framework\TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[],
|
[
|
||||||
|
'4' => 5,
|
||||||
|
'3' => 3,
|
||||||
|
'3:4' => 3,
|
||||||
|
'2' => 5,
|
||||||
|
'2:4' => 4,
|
||||||
|
'2:3' => 2,
|
||||||
|
'2:3:4' => 2,
|
||||||
|
'1' => 3,
|
||||||
|
'1:4' => 2,
|
||||||
|
'1:3' => 1,
|
||||||
|
'1:3:4' => 1,
|
||||||
|
'1:2' => 3,
|
||||||
|
'1:2:4' => 2,
|
||||||
|
'1:2:3' => 1,
|
||||||
|
'1:2:3:4' => 1,
|
||||||
|
],
|
||||||
Apriori::apriori([
|
Apriori::apriori([
|
||||||
[1, 2, 3, 4],
|
['1', '2', '3', '4'],
|
||||||
[1, 2, 4],
|
['1', '2', '4'],
|
||||||
[1, 2],
|
['1', '2'],
|
||||||
[2, 3, 4],
|
['2', '3', '4'],
|
||||||
[3, 4],
|
['3', '4'],
|
||||||
[2, 4],
|
['2', '4'],
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -85,14 +101,14 @@ final class AprioriTest extends \PHPUnit\Framework\TestCase
|
||||||
['2:3' => 2],
|
['2:3' => 2],
|
||||||
Apriori::apriori(
|
Apriori::apriori(
|
||||||
[
|
[
|
||||||
[1, 2, 3, 4],
|
['1', '2', '3', '4'],
|
||||||
[1, 2, 4],
|
['1', '2', '4'],
|
||||||
[1, 2],
|
['1', '2'],
|
||||||
[2, 3, 4],
|
['2', '3', '4'],
|
||||||
[3, 4],
|
['3', '4'],
|
||||||
[2, 4],
|
['2', '4'],
|
||||||
],
|
],
|
||||||
[2, 3]
|
['2', '3']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,17 +26,23 @@ require_once __DIR__ . '/../../Autoloader.php';
|
||||||
final class DependencyResolverTest extends \PHPUnit\Framework\TestCase
|
final class DependencyResolverTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @testdox A value is matched with the minimum quantity of available coins.
|
* @covers phpOMS\Algorithm\Graph\DependencyResolver
|
||||||
|
* @group framework
|
||||||
|
*/
|
||||||
|
public function testResolveCircular() : void
|
||||||
|
{
|
||||||
|
self::assertEquals(
|
||||||
|
null,
|
||||||
|
DependencyResolver::resolve([0 => [1, 2], 1 => [0, 2], 2 => []])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @covers phpOMS\Algorithm\Graph\DependencyResolver
|
* @covers phpOMS\Algorithm\Graph\DependencyResolver
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
public function testResolve() : void
|
public function testResolve() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(
|
|
||||||
null,
|
|
||||||
DependencyResolver::resolve([0 => [1, 2], 1 => [0, 2], 2 => []])
|
|
||||||
);
|
|
||||||
|
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[0, 1, 2, 3],
|
[0, 1, 2, 3],
|
||||||
DependencyResolver::resolve([0 => [1, 2], 1 => [2, 3], 2 => [], 3 => []])
|
DependencyResolver::resolve([0 => [1, 2], 1 => [2, 3], 2 => [], 3 => []])
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,12 @@ class BaseModelMapper extends DataMapperFactory
|
||||||
'belongsToOne' => [
|
'belongsToOne' => [
|
||||||
'mapper' => BelongsToModelMapper::class,
|
'mapper' => BelongsToModelMapper::class,
|
||||||
'external' => 'test_base_belongs_to_one',
|
'external' => 'test_base_belongs_to_one',
|
||||||
|
'private' => true,
|
||||||
],
|
],
|
||||||
'belongsToOnePrivate' => [
|
'belongsToOnePrivate' => [
|
||||||
'mapper' => BelongsToModelMapper::class,
|
'mapper' => BelongsToModelMapper::class,
|
||||||
'external' => 'test_base_belongs_to_one',
|
'external' => 'test_base_belongs_to_one',
|
||||||
|
'private' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user