From bb846a0e271a068d493cbfb5821b28b2cd5ef4b8 Mon Sep 17 00:00:00 2001 From: aho Date: Tue, 22 Oct 2019 15:07:20 +0200 Subject: [PATCH 1/4] Bugfixes for issue23 --- R/ByChunks.R | 7 ++++++- R/Utils.R | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/R/ByChunks.R b/R/ByChunks.R index 4560121..ed036c1 100644 --- a/R/ByChunks.R +++ b/R/ByChunks.R @@ -5,7 +5,7 @@ ByChunks <- function(step_fun, cube_headers, ..., chunks = 'auto', ecflow_server = NULL, silent = FALSE, debug = FALSE, wait = TRUE) { - +print('hi!!!') # Build object to store profiling timings t_begin_total <- Sys.time() t_begin_bychunks_setup <- t_begin_total @@ -598,6 +598,9 @@ ByChunks <- function(step_fun, cube_headers, ..., chunks = 'auto', names_dims_to_alter <- names(attr(start_call, 'Dimensions'))[dims_to_alter] # If any dimension comes from split dimensions split_dims <- attr(start_call, 'SplitDims') + + if (length(split_dims) != 0){ + for (k in 1:length(split_dims)) { if (any(names(split_dims[[k]]) %in% names_dims_to_alter)) { chunks_split_dims <- rep(1, length(split_dims[[k]])) @@ -615,6 +618,8 @@ ByChunks <- function(step_fun, cube_headers, ..., chunks = 'auto', } } } + } + if (length(dims_to_alter) > 0) { for (call_dim in names(attr(start_call, 'Dimensions'))[dims_to_alter]) { start_call[[call_dim]] <- chunk(chunk_indices[call_dim], chunks[[call_dim]], diff --git a/R/Utils.R b/R/Utils.R index 8626b2a..0d2b2fd 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -30,7 +30,7 @@ chunk <- function(chunk, n_chunks, selectors) { if (length(chunk) != length(n_chunks)) { stop("Wrong chunk specification.") } - if (!attr(selectors, 'values')) { + if (!is.null(attr(selectors, 'values'))) { stop("Multidimensional chunking only available when selector ", "values provided.") } -- GitLab From d17d2ec4663801556ec988e0a6f2b937eb71eaae Mon Sep 17 00:00:00 2001 From: aho Date: Tue, 22 Oct 2019 15:07:20 +0200 Subject: [PATCH 2/4] Bugfixes for issue23 --- R/ByChunks.R | 6 +++++- R/Utils.R | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/R/ByChunks.R b/R/ByChunks.R index 4560121..26d6662 100644 --- a/R/ByChunks.R +++ b/R/ByChunks.R @@ -5,7 +5,6 @@ ByChunks <- function(step_fun, cube_headers, ..., chunks = 'auto', ecflow_server = NULL, silent = FALSE, debug = FALSE, wait = TRUE) { - # Build object to store profiling timings t_begin_total <- Sys.time() t_begin_bychunks_setup <- t_begin_total @@ -598,6 +597,9 @@ ByChunks <- function(step_fun, cube_headers, ..., chunks = 'auto', names_dims_to_alter <- names(attr(start_call, 'Dimensions'))[dims_to_alter] # If any dimension comes from split dimensions split_dims <- attr(start_call, 'SplitDims') + + if (length(split_dims) != 0){ + for (k in 1:length(split_dims)) { if (any(names(split_dims[[k]]) %in% names_dims_to_alter)) { chunks_split_dims <- rep(1, length(split_dims[[k]])) @@ -615,6 +617,8 @@ ByChunks <- function(step_fun, cube_headers, ..., chunks = 'auto', } } } + } + if (length(dims_to_alter) > 0) { for (call_dim in names(attr(start_call, 'Dimensions'))[dims_to_alter]) { start_call[[call_dim]] <- chunk(chunk_indices[call_dim], chunks[[call_dim]], diff --git a/R/Utils.R b/R/Utils.R index 8626b2a..0d2b2fd 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -30,7 +30,7 @@ chunk <- function(chunk, n_chunks, selectors) { if (length(chunk) != length(n_chunks)) { stop("Wrong chunk specification.") } - if (!attr(selectors, 'values')) { + if (!is.null(attr(selectors, 'values'))) { stop("Multidimensional chunking only available when selector ", "values provided.") } -- GitLab From 569fb50ab1a348c9fbfdd88702eca94644a3e1d2 Mon Sep 17 00:00:00 2001 From: aho Date: Tue, 22 Oct 2019 15:11:55 +0200 Subject: [PATCH 3/4] Delete print line --- R/ByChunks.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/ByChunks.R b/R/ByChunks.R index 26d6662..a6a87f8 100644 --- a/R/ByChunks.R +++ b/R/ByChunks.R @@ -5,6 +5,7 @@ ByChunks <- function(step_fun, cube_headers, ..., chunks = 'auto', ecflow_server = NULL, silent = FALSE, debug = FALSE, wait = TRUE) { + # Build object to store profiling timings t_begin_total <- Sys.time() t_begin_bychunks_setup <- t_begin_total -- GitLab From a6c35016736721f28ca776818ebaff5580b2db4c Mon Sep 17 00:00:00 2001 From: aho Date: Tue, 22 Oct 2019 15:13:54 +0200 Subject: [PATCH 4/4] Delete test print line --- R/ByChunks.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/ByChunks.R b/R/ByChunks.R index ed036c1..26d6662 100644 --- a/R/ByChunks.R +++ b/R/ByChunks.R @@ -5,7 +5,6 @@ ByChunks <- function(step_fun, cube_headers, ..., chunks = 'auto', ecflow_server = NULL, silent = FALSE, debug = FALSE, wait = TRUE) { -print('hi!!!') # Build object to store profiling timings t_begin_total <- Sys.time() t_begin_bychunks_setup <- t_begin_total -- GitLab