<commit_before><?php

/**
 * This function partitions an array into n subarrays which can be used for column layouts.
 *
 * @param array                    $params   An array consisting of the keys array, size, and name; name is the name of the output array, size is the number of columns, array is the array to be partitioned
 * @param Smarty_Internal_Template $template Used by Smarty internally
 *
 * @return array Returns the partitoned array
 */
function smarty_function_partition($params, Smarty_Internal_Template $template = null)
{
    // First, we inline the parameters into better understandable variables.
    $numberOfParts = $params['size'];
    $inputList = $params['array'];
    $outputName = $params['name'];

    // If the number of parts requested is non-positive, error out.
    if ((int) $numberOfParts <= 0) {
        if (!empty($template)) {
            $template->assign($outputName, []);
            return;
        } else {
            return [$outputName => []];
        }
    }

    // Set up the loop to split the input up.
    $lengthOfList = count($inputList);
    $lengthOfOnePart = floor($lengthOfList / $numberOfParts);
    $lengthOfRemainder = $lengthOfList % $numberOfParts;
    $partition = [];
    $mark = 0;

    // Loop over the array and fill the columns.
    // The first column may contain up to (n -1) more elements than the other columns.
    // n is equal to the number of parts.
    for ($px = 0; $px < $numberOfParts; $px++) {
        $increment = ($px < $lengthOfRemainder) ? $lengthOfOnePart + 1 : $lengthOfOnePart;
        $partition[$px] = array_slice($inputList ?: [], $mark, $increment);
        $mark += $increment;
    }

    // Return the partitioned array with the pre-defined name.<commit_msg>one style fix<commit_after><?php

/**
 * This function partitions an array into n subarrays which can be used for column layouts.
 *
 * @param array                    $params   An array consisting of the keys array, size, and name; name is the name of the output array, size is the number of columns, array is the array to be partitioned
 * @param Smarty_Internal_Template $template Used by Smarty internally
 *
 * @return array Returns the partitoned array
 */
function smarty_function_partition($params, Smarty_Internal_Template $template = null)
{
    // First, we inline the parameters into better understandable variables.
    $numberOfParts = $params['size'];
    $inputList = $params['array'];
    $outputName = $params['name'];

    // If the number of parts requested is non-positive, error out.
    if ((int) $numberOfParts <= 0) {
        if (!empty($template)) {
            $template->assign($outputName, []);

            return;
        } else {
            return [$outputName => []];
        }
    }

    // Set up the loop to split the input up.
    $lengthOfList = count($inputList);
    $lengthOfOnePart = floor($lengthOfList / $numberOfParts);
    $lengthOfRemainder = $lengthOfList % $numberOfParts;
    $partition = [];
    $mark = 0;

    // Loop over the array and fill the columns.
    // The first column may contain up to (n -1) more elements than the other columns.
    // n is equal to the number of parts.
    for ($px = 0; $px < $numberOfParts; $px++) {
        $increment = ($px < $lengthOfRemainder) ? $lengthOfOnePart + 1 : $lengthOfOnePart;
        $partition[$px] = array_slice($inputList ?: [], $mark, $increment);
        $mark += $increment;
    }

    // Return the partitioned array with the pre-defined name.
{'fraction_non_alphanumeric': 0.11475877819012276, 'fraction_numerical': 0.0028546959748786756, 'mean_word_length': 2.8505494505494506, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '3269595', 'n_tokens_mistral': 1003, 'n_tokens_neox': 969, 'n_words': 363}