Skip to content

Commit

Permalink
fix(deps): Use php-scoper on all dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Jan 24, 2024
1 parent f624654 commit b3516e4
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 39 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
"test:unit": "phpunit --config tests/phpunit.xml",
"post-install-cmd": [
"@composer bin all install --ansi",
"grep -r 'OCA\\\\Recognize\\\\Rubix' ./vendor/rubix/ml/ || ( vendor/bin/php-scoper add-prefix --prefix='OCA\\Recognize' --output-dir=\".\" --working-dir=\"./vendor/rubix/ml/\" -f --config=\"../../../scoper.inc.php\" && sed -i 's:Rubix\\\\\\\\ML\\\\\\\\:OCA\\\\\\\\Recognize\\\\\\\\Rubix\\\\\\\\ML\\\\\\\\:' vendor/composer/installed.json )",
"grep -r 'OCA\\\\Recognize\\\\Vendor\\\\Rubix' ./vendor/rubix/ml/ || vendor/bin/php-scoper add-prefix --prefix='OCA\\Recognize\\Vendor' --output-dir=\".\" --working-dir=\"./vendor/\" -f --config=\"../scoper.inc.php\"",
"composer dump-autoload"
],
"post-update-cmd": [
"@composer bin all update --ansi",
"grep -r 'OCA\\\\Recognize\\\\Rubix' ./vendor/rubix/ml/ || ( vendor/bin/php-scoper add-prefix --prefix='OCA\\Recognize' --output-dir=\".\" --working-dir=\"./vendor/rubix/ml/\" -f --config=\"../../../scoper.inc.php\" && sed -i 's:Rubix\\\\\\\\ML\\\\\\\\:OCA\\\\\\\\Recognize\\\\\\\\Rubix\\\\\\\\ML\\\\\\\\:' vendor/composer/installed.json )",
"grep -r 'OCA\\\\Recognize\\\\Vendor\\\\Rubix' ./vendor/rubix/ml/ || vendor/bin/php-scoper add-prefix --prefix='OCA\\Recognize\\Vendor' --output-dir=\".\" --working-dir=\"./vendor/\" -f --config=\"../scoper.inc.php\"",
"composer dump-autoload"
]
},
Expand Down
4 changes: 3 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public function __construct() {
}

public function register(IRegistrationContext $context): void {
@include_once __DIR__ . '/../../vendor/autoload.php';
@include_once __DIR__ . '/../../vendor/scoper-autoload.php';
@include_once __DIR__ . '/../../vendor/rubix/ml/src/functions.php';
@include_once __DIR__ . '/../../vendor/rubix/ml/src/constants.php';

/** Register $principalBackend for the DAV collection */
$context->registerServiceAlias('principalBackend', Principal::class);
Expand Down
14 changes: 7 additions & 7 deletions lib/Clustering/DualTreeBall.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
declare(strict_types=1);
namespace OCA\Recognize\Clustering;

use \OCA\Recognize\Rubix\ML\Datasets\Labeled;
use \OCA\Recognize\Rubix\ML\Graph\Nodes\Ball;
use \OCA\Recognize\Rubix\ML\Helpers\Stats;
use \OCA\Recognize\Rubix\ML\Kernels\Distance\Distance;
use function \OCA\Recognize\Rubix\ML\argmax;
use \OCA\Recognize\Vendor\Rubix\ML\Datasets\Labeled;
use \OCA\Recognize\Vendor\Rubix\ML\Graph\Nodes\Ball;
use \OCA\Recognize\Vendor\Rubix\ML\Helpers\Stats;
use \OCA\Recognize\Vendor\Rubix\ML\Kernels\Distance\Distance;
use function \OCA\Recognize\Vendor\Rubix\ML\argmax;

class DualTreeBall extends Ball {
protected float $longestDistanceInNode = INF;
Expand Down Expand Up @@ -97,8 +97,8 @@ public function propagateSetChanges(array &$labelToSetId) {
/**
* Factory method to build a hypersphere by splitting the dataset into left and right clusters.
*
* @param \OCA\Recognize\Rubix\ML\Datasets\Labeled $dataset
* @param \OCA\Recognize\Rubix\ML\Kernels\Distance\Distance $kernel
* @param \OCA\Recognize\Vendor\Rubix\ML\Datasets\Labeled $dataset
* @param \OCA\Recognize\Vendor\Rubix\ML\Kernels\Distance\Distance $kernel
* @return self
*/
public static function split(Labeled $dataset, Distance $kernel): self {
Expand Down
14 changes: 7 additions & 7 deletions lib/Clustering/DualTreeClique.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
declare(strict_types=1);
namespace OCA\Recognize\Clustering;

use \OCA\Recognize\Rubix\ML\Datasets\Labeled;
use \OCA\Recognize\Rubix\ML\Graph\Nodes\Clique;
use \OCA\Recognize\Rubix\ML\Helpers\Stats;
use \OCA\Recognize\Rubix\ML\Kernels\Distance\Distance;
use function \OCA\Recognize\Rubix\ML\argmax;
use \OCA\Recognize\Vendor\Rubix\ML\Datasets\Labeled;
use \OCA\Recognize\Vendor\Rubix\ML\Graph\Nodes\Clique;
use \OCA\Recognize\Vendor\Rubix\ML\Helpers\Stats;
use \OCA\Recognize\Vendor\Rubix\ML\Kernels\Distance\Distance;
use function \OCA\Recognize\Vendor\Rubix\ML\argmax;

class DualTreeClique extends Clique {
protected float $longestDistanceInNode = INF;
Expand Down Expand Up @@ -80,8 +80,8 @@ public function propagateSetChanges(array &$labelToSetId) {
/**
* Terminate a branch with a dataset.
*
* @param \OCA\Recognize\Rubix\ML\Datasets\Labeled $dataset
* @param \OCA\Recognize\Rubix\ML\Kernels\Distance\Distance $kernel
* @param \OCA\Recognize\Vendor\Rubix\ML\Datasets\Labeled $dataset
* @param \OCA\Recognize\Vendor\Rubix\ML\Kernels\Distance\Distance $kernel
* @return self
*/
public static function terminate(Labeled $dataset, Distance $kernel): self {
Expand Down
24 changes: 12 additions & 12 deletions lib/Clustering/MrdBallTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
declare(strict_types=1);
namespace OCA\Recognize\Clustering;

use \OCA\Recognize\Rubix\ML\Datasets\Labeled;
use \OCA\Recognize\Rubix\ML\Graph\Nodes\Ball;
use \OCA\Recognize\Rubix\ML\Graph\Nodes\Hypersphere;
use \OCA\Recognize\Rubix\ML\Graph\Trees\BallTree;
use \OCA\Recognize\Rubix\ML\Kernels\Distance\Distance;
use \OCA\Recognize\Vendor\Rubix\ML\Datasets\Labeled;
use \OCA\Recognize\Vendor\Rubix\ML\Graph\Nodes\Ball;
use \OCA\Recognize\Vendor\Rubix\ML\Graph\Nodes\Hypersphere;
use \OCA\Recognize\Vendor\Rubix\ML\Graph\Trees\BallTree;
use \OCA\Recognize\Vendor\Rubix\ML\Kernels\Distance\Distance;

class MrdBallTree extends BallTree {
private ?Labeled $dataset = null;
Expand All @@ -25,8 +25,8 @@ class MrdBallTree extends BallTree {
/**
* @param int $maxLeafSize
* @param int $coreDistSampleSize
* @param \OCA\Recognize\Rubix\ML\Kernels\Distance\Distance|null $kernel
* @throws \OCA\Recognize\Rubix\ML\Exceptions\InvalidArgumentException
* @param \OCA\Recognize\Vendor\Rubix\ML\Kernels\Distance\Distance|null $kernel
* @throws \OCA\Recognize\Vendor\Rubix\ML\Exceptions\InvalidArgumentException
*/
public function __construct(int $maxLeafSize = 30, int $sampleSize = 5, ?Distance $kernel = null) {
if ($maxLeafSize < 1) {
Expand Down Expand Up @@ -462,7 +462,7 @@ public function cachedComputeNative($a, array $a_vector, $b, array $b_vector, bo
*
* @param int|string $sampleLabel
* @param bool $useCachedValues
* @throws \OCA\Recognize\Rubix\ML\Exceptions\InvalidArgumentException
* @throws \OCA\Recognize\Vendor\Rubix\ML\Exceptions\InvalidArgumentException
* @return array{list<mixed>,list<float>}
*/
public function getCoreNeighbors($sampleLabel, bool $useCachedValues = true): array {
Expand Down Expand Up @@ -546,8 +546,8 @@ public function getCoreNeighbors($sampleLabel, bool $useCachedValues = true): ar
*
* @param int $sampleLabel
* @param float $radius
* @throws \OCA\Recognize\Rubix\ML\Exceptions\InvalidArgumentException
* @throws \OCA\Recognize\Rubix\ML\Exceptions\RuntimeException
* @throws \OCA\Recognize\Vendor\Rubix\ML\Exceptions\InvalidArgumentException
* @throws \OCA\Recognize\Vendor\Rubix\ML\Exceptions\RuntimeException
* @return array{list<mixed>,list<float>}
*/
public function cachedRange($sampleLabel, float $radius): array {
Expand Down Expand Up @@ -624,8 +624,8 @@ public function cachedRange($sampleLabel, float $radius): array {
*
* @internal
*
* @param \OCA\Recognize\Rubix\ML\Datasets\Labeled $dataset
* @throws \OCA\Recognize\Rubix\ML\Exceptions\InvalidArgumentException
* @param \OCA\Recognize\Vendor\Rubix\ML\Datasets\Labeled $dataset
* @throws \OCA\Recognize\Vendor\Rubix\ML\Exceptions\InvalidArgumentException
*/
public function grow(Labeled $dataset): void {
$this->dataset = $dataset;
Expand Down
4 changes: 2 additions & 2 deletions lib/Clustering/MstSolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
declare(strict_types=1);
namespace OCA\Recognize\Clustering;

use \OCA\Recognize\Rubix\ML\Datasets\Labeled;
use \OCA\Recognize\Rubix\ML\Kernels\Distance\Distance;
use \OCA\Recognize\Vendor\Rubix\ML\Datasets\Labeled;
use \OCA\Recognize\Vendor\Rubix\ML\Kernels\Distance\Distance;

class MstSolver {
private MrdBallTree $tree;
Expand Down
6 changes: 3 additions & 3 deletions lib/Clustering/SquaredDistance.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
declare(strict_types=1);
namespace OCA\Recognize\Clustering;

use \OCA\Recognize\Rubix\ML\DataType;
use \OCA\Recognize\Rubix\ML\Kernels\Distance\Distance;
use \OCA\Recognize\Vendor\Rubix\ML\DataType;
use \OCA\Recognize\Vendor\Rubix\ML\Kernels\Distance\Distance;

/**
* Squared distance
Expand All @@ -24,7 +24,7 @@ class SquaredDistance implements Distance {
*
* @internal
*
* @return list<\OCA\Recognize\Rubix\ML\DataType>
* @return list<\OCA\Recognize\Vendor\Rubix\ML\DataType>
*/
public function compatibility(): array {
return [
Expand Down
2 changes: 1 addition & 1 deletion lib/Dav/Faces/FacePhoto.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
declare(strict_types=1);
namespace OCA\Recognize\Dav\Faces;

use \OCA\Recognize\Rubix\ML\Kernels\Distance\Euclidean;
use \OCA\Recognize\Vendor\Rubix\ML\Kernels\Distance\Euclidean;
use OCA\Recognize\Db\FaceDetection;
use OCA\Recognize\Db\FaceDetectionMapper;
use OCA\Recognize\Service\FaceClusterAnalyzer;
Expand Down
8 changes: 5 additions & 3 deletions lib/Service/FaceClusterAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
declare(strict_types=1);
namespace OCA\Recognize\Service;

use \OCA\Recognize\Rubix\ML\Datasets\Labeled;
use \OCA\Recognize\Rubix\ML\Kernels\Distance\Euclidean;
use \OCA\Recognize\Vendor\Rubix\ML\Datasets\Labeled;
use \OCA\Recognize\Vendor\Rubix\ML\Kernels\Distance\Euclidean;
use OCA\Recognize\Clustering\HDBSCAN;
use OCA\Recognize\Db\FaceCluster;
use OCA\Recognize\Db\FaceClusterMapper;
Expand Down Expand Up @@ -51,7 +51,7 @@ public function calculateClusters(string $userId, int $batchSize = 0): void {
ini_set('memory_limit', '-1');
}


$sampledDetections = [];
$existingClusters = $this->faceClusters->findByUserId($userId);
/** @var array<int,int> $maxVotesByCluster */
Expand Down Expand Up @@ -87,6 +87,8 @@ public function calculateClusters(string $userId, int $batchSize = 0): void {
return $detection->getVector();
}, $detections), array_combine(array_keys($detections), array_keys($detections)), false);

$dataset->features();

$n = count($detections);
$hdbscan = new HDBSCAN($dataset, $this->getMinClusterSize($n), $this->getMinSampleSize($n));

Expand Down
2 changes: 1 addition & 1 deletion tests/ClusterTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use \OCA\Recognize\Rubix\ML\Kernels\Distance\Euclidean;
use \OCA\Recognize\Vendor\Rubix\ML\Kernels\Distance\Euclidean;
use OCA\Recognize\Db\FaceClusterMapper;
use OCA\Recognize\Db\FaceDetection;
use OCA\Recognize\Db\FaceDetectionMapper;
Expand Down

0 comments on commit b3516e4

Please sign in to comment.