<commit_before>#' Apply function that preserves order of dimensions
#'
#' @param X        An n-dimensional array
#' @param along    Along which axis to apply the function
#' @param FUN      A function that maps a vector to the same length or a scalar
#' @param drop     Remove unused dimensions after mapping; default: TRUE
#' @param ...      Arguments passed to the function
#' @return         An array where \code{FUN} has been applied
map_simple = function(X, along, FUN, drop=TRUE, ...) {
    if (is.vector(X) || length(dim(X))==1)
        return(FUN(X, ...))

    preserveAxes = c(1:length(dim(X)))[-along]
    Y = as.array(apply(X, preserveAxes, FUN))<commit_msg>pass additional args to apply<commit_after>#' Apply function that preserves order of dimensions
#'
#' @param X        An n-dimensional array
#' @param along    Along which axis to apply the function
#' @param FUN      A function that maps a vector to the same length or a scalar
#' @param drop     Remove unused dimensions after mapping; default: TRUE
#' @param ...      Arguments passed to the function
#' @return         An array where \code{FUN} has been applied
map_simple = function(X, along, FUN, drop=TRUE, ...) {
    if (is.vector(X) || length(dim(X))==1)
        return(FUN(X, ...))

    preserveAxes = c(1:length(dim(X)))[-along]
    Y = as.array(apply(X, preserveAxes, FUN, ...))
{'fraction_non_alphanumeric': 0.12950699043414277, 'fraction_numerical': 0.0029433406916850625, 'mean_word_length': 3.236760124610592, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4066741', 'n_tokens_mistral': 415, 'n_tokens_neox': 386, 'n_words': 153}