dataset = new Unlabeled([ [1, 2, 3, 4], [40, 20, 30, 10], [100, 300, 200, 400], ]); $callback = function (&$sample, $index, $context) { $sample = [$index, array_sum($sample), $context]; }; $this->transformer = new LambdaFunction($callback, 'context'); } /** * @test */ public function build() : void { $this->assertInstanceOf(LambdaFunction::class, $this->transformer); $this->assertInstanceOf(Transformer::class, $this->transformer); } /** * @test */ public function transform() : void { $this->dataset->apply($this->transformer); $expected = [ [0, 10, 'context'], [1, 100, 'context'], [2, 1000, 'context'], ]; $this->assertEquals($expected, $this->dataset->samples()); } }