diff --git a/R/ByChunks.R b/R/ByChunks.R index c43f4d14c28fba3b4cc0eda1172e191a92d2cf8b..933fc71f9147585df7283f92d6bc99625abaf5e5 100644 --- a/R/ByChunks.R +++ b/R/ByChunks.R @@ -233,7 +233,7 @@ ByChunks <- function(step_fun, cube_headers, ..., chunks = 'auto', if (is.null(all_dims_merged)) { all_dims_merged <- i } else { - all_dims_merged <- startR:::.MergeArrayDims(all_dims_merged, i)[[1]] + all_dims_merged <- startR:::.MergeArrayDims(all_dims_merged, i)[[3]] } } all_dimnames <- names(all_dims_merged) diff --git a/R/Start.R b/R/Start.R index fc05ee5495ffabf03263108cc8c84589d7f77282..168fae710c96085dfd34e22610febae131ea90a9 100644 --- a/R/Start.R +++ b/R/Start.R @@ -2461,12 +2461,12 @@ print("-> PROCEEDING TO CROP VARIABLES") total_inner_dims <- inner_dims } else { new_dims <- .MergeArrayDims(total_inner_dims, inner_dims) - total_inner_dims <- pmax(new_dims[[1]], new_dims[[2]]) + total_inner_dims <- new_dims[[3]] } } } new_dims <- .MergeArrayDims(dim(array_of_files_to_load), total_inner_dims) - final_dims <- pmax(new_dims[[1]], new_dims[[2]])[dim_names] + final_dims <- new_dims[[3]][dim_names] # final_dims_fake is the vector of final dimensions after having merged the # 'across' file dimensions with the respective 'across' inner dimensions, and # after having broken into multiple dimensions those dimensions for which diff --git a/R/Utils.R b/R/Utils.R index 6f7b6a17758e661fd42a1b59648c3a960cc6f2e5..0d1fdc65f7309b2801c27077541fa639c2bd72bc 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -528,6 +528,11 @@ chunk <- function(chunk, n_chunks, selectors) { # It expects as inputs two named numeric vectors, and it extends them # with dimensions of length 1 until an ordered common dimension # format is reached. +# The first output is dims1 extended with 1s. +# The second output is dims2 extended with 1s. +# The third output is a merged dimension vector. If dimensions with +# the same name are found in the two inputs, and they have a different +# length, the maximum is taken. .MergeArrayDims <- function(dims1, dims2) { new_dims1 <- c() new_dims2 <- c() @@ -555,7 +560,7 @@ chunk <- function(chunk, n_chunks, selectors) { new_dims1 <- c(new_dims1, dims_to_add) new_dims2 <- c(new_dims2, dims2) } - list(new_dims1, new_dims2) + list(new_dims1, new_dims2, pmax(new_dims1, new_dims2)) } # This function takes two named arrays and merges them, filling with