<commit_before><?php
namespace Eris\Generator;
use Eris\Generator;

class Vector implements Generator
{
    private $size;
    private $vector;
    private $lastGenerated;

    public function __construct($size = 1, Generator $elementsGenerator)
    {
        $this->size = $size;
        $this->vector = $this->initialize(
            $size,
            $elementsGenerator
        );
    }

    public function __invoke()
    {
        $this->lastGenerated = $this->generateElements();

        return $this->lastGenerated;
    }

    public function shrink()
    {
        $elementsToShrink = rand(1, (int)(($this->size - 1)/2));

        for ($i = 0; $i < $elementsToShrink; $i++) {
            $elementToShrink = rand(0, $this->size - 1);

            $shrinkedElement = $this->vector[$elementToShrink]->shrink();
            $this->lastGenerated[$elementToShrink] = $shrinkedElement;
        }

        return $this->lastGenerated;
    }

    private function initialize($size, Generator $generator)
    {
        $vector = [];
        for ($i = 0; $i < $size; $i++) {
            $elementGenerator = clone $generator;
            $vector[] = $elementGenerator;
        }

        return $vector;
    }

    private function generateElements()
    {
        $sampleVector = [];
        foreach ($this->vector as $elementGenerator) {
            $sampleVector[] = $elementGenerator();
        }

        return $sampleVector;
    }
}
<commit_msg>A more aggressive shrink policy for Vectors<commit_after><?php
namespace Eris\Generator;
use Eris\Generator;

class Vector implements Generator
{
    private $size;
    private $vector;
    private $lastGenerated;

    public function __construct($size = 1, Generator $elementsGenerator)
    {
        $this->size = $size;
        $this->vector = $this->initialize(
            $size,
            $elementsGenerator
        );
    }

    public function __invoke()
    {
        $this->lastGenerated = $this->generateElements();

        return $this->lastGenerated;
    }

    public function shrink()
    {
        $elementsToShrink = rand(1, (int)($this->size/2));

        for ($i = 0; $i < $elementsToShrink; $i++) {
            $elementToShrink = rand(0, $this->size - 1);

            $shrinkedElement = $this->vector[$elementToShrink]->shrink();
            $this->lastGenerated[$elementToShrink] = $shrinkedElement;
        }

        return $this->lastGenerated;
    }

    private function initialize($size, Generator $generator)
    {
        $vector = [];
        for ($i = 0; $i < $size; $i++) {
            $elementGenerator = clone $generator;
            $vector[] = $elementGenerator;
        }

        return $vector;
    }

    private function generateElements()
    {
        $sampleVector = [];
        foreach ($this->vector as $elementGenerator) {
            $sampleVector[] = $elementGenerator();
        }

        return $sampleVector;
    }
}

{'fraction_non_alphanumeric': 0.13440492476060192, 'fraction_numerical': 0.005129958960328317, 'mean_word_length': 2.1519396551724137, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '640951', 'n_tokens_mistral': 863, 'n_tokens_neox': 824, 'n_words': 181}