From 1371e3894d92fef98ae1b7c5f3a1dad6797cec62 Mon Sep 17 00:00:00 2001 From: vagudets Date: Thu, 7 Aug 2025 14:32:16 +0200 Subject: [PATCH 1/8] Always define 'indices_chunk' --- R/Start.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/Start.R b/R/Start.R index 5bb0bda2..62c47bfb 100644 --- a/R/Start.R +++ b/R/Start.R @@ -2752,6 +2752,7 @@ Start <- function(..., # dim = indices/selectors, # The inner dim selector is an array in which have file dim (e.g., time = [sdate = 2, time = 4], # or the inner dim doesn't go across any file dim (e.g., no time_across = 'sdate') + indices_chunk <- c() if ((!is.null(crossed_file_dim) & (any(crossed_file_dim %in% names(selector_file_dims)))) || is.null(crossed_file_dim)) { if (length(sub_array_of_selectors) > 0) { if (debug) { -- GitLab From ad913e538cfc9b53c60b7613c11ecc8895bb9858 Mon Sep 17 00:00:00 2001 From: vagudets Date: Fri, 29 Aug 2025 16:26:12 +0200 Subject: [PATCH 2/8] Reshape metadata when retrieve = FALSE --- R/Start.R | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/R/Start.R b/R/Start.R index 62c47bfb..19dcf7e1 100644 --- a/R/Start.R +++ b/R/Start.R @@ -2048,11 +2048,15 @@ Start <- function(..., # dim = indices/selectors, # Not all the inner dims are defined in Start() call if (!all(names(data_dims) %in% expected_inner_dims[[i]])) { tmp <- names(data_dims)[which(!names(data_dims) %in% expected_inner_dims[[i]])] - undefined_dims <- tmp[data_dims[tmp] != 1] - if (length(undefined_dims > 0)) { - stop("The dimension(s) '", paste(undefined_dims, collapse = ", "), - "' is found in the file ", file_path, + if (data_dims[tmp] != 1) { + stop("The dimension '", tmp, "' is found in the file ", file_path, " but not defined in the Start call.") + # undefined_dims <- tmp[data_dims[tmp] != 1] + # if (length(undefined_dims > 0)) { + # stop("The dimension(s) '", paste(undefined_dims, collapse = ", "), + # "' is found in the file ", file_path, + # " but not defined in the Start call.") + # } } } @@ -2752,7 +2756,7 @@ Start <- function(..., # dim = indices/selectors, # The inner dim selector is an array in which have file dim (e.g., time = [sdate = 2, time = 4], # or the inner dim doesn't go across any file dim (e.g., no time_across = 'sdate') - indices_chunk <- c() + # indices_chunk <- c() if ((!is.null(crossed_file_dim) & (any(crossed_file_dim %in% names(selector_file_dims)))) || is.null(crossed_file_dim)) { if (length(sub_array_of_selectors) > 0) { if (debug) { @@ -4064,6 +4068,7 @@ Start <- function(..., # dim = indices/selectors, else { # if retrieve = FALSE, metadata still needs to reshape if (merge_across_dims & (split_multiselected_dims | merge_across_dims_narm)) { + indices_chunk <- c() if (!merge_across_dims_narm) { tmp <- match(names(final_dims), names(dims_of_merge_dim)) if (any(diff(tmp[!is.na(tmp)]) < 0)) { #need to reorder -- GitLab From 1a8626108979e689a5765ea0f9230462466014f4 Mon Sep 17 00:00:00 2001 From: vagudets Date: Fri, 29 Aug 2025 16:28:07 +0200 Subject: [PATCH 3/8] Recover previous error message bugfix --- R/Start.R | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/R/Start.R b/R/Start.R index 19dcf7e1..53735ed7 100644 --- a/R/Start.R +++ b/R/Start.R @@ -2048,16 +2048,12 @@ Start <- function(..., # dim = indices/selectors, # Not all the inner dims are defined in Start() call if (!all(names(data_dims) %in% expected_inner_dims[[i]])) { tmp <- names(data_dims)[which(!names(data_dims) %in% expected_inner_dims[[i]])] - if (data_dims[tmp] != 1) { - stop("The dimension '", tmp, "' is found in the file ", file_path, + undefined_dims <- tmp[data_dims[tmp] != 1] + if (length(undefined_dims > 0)) { + stop("The dimension(s) '", paste(undefined_dims, collapse = ", "), + "' is found in the file ", file_path, " but not defined in the Start call.") - # undefined_dims <- tmp[data_dims[tmp] != 1] - # if (length(undefined_dims > 0)) { - # stop("The dimension(s) '", paste(undefined_dims, collapse = ", "), - # "' is found in the file ", file_path, - # " but not defined in the Start call.") - # } - } + } } -- GitLab From b2c9c2d52af7da411d7c3dce3f0f3c45dbf09260 Mon Sep 17 00:00:00 2001 From: vagudets Date: Fri, 29 Aug 2025 16:31:45 +0200 Subject: [PATCH 4/8] Unignore unit tests --- .Rbuildignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Rbuildignore b/.Rbuildignore index d79d3e82..a47542c8 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,7 +9,7 @@ ^inst/doc$ ^\.gitlab-ci\.yml$ ## unit tests should be ignored when building the package for CRAN -^tests$ +# ^tests$ ^inst/PlotProfiling\.R$ ^.gitlab$ # Suggested by http://r-pkgs.had.co.nz/package.html -- GitLab From ff8d1676427ec33d0fa91218159e6bee73febd73 Mon Sep 17 00:00:00 2001 From: vagudets Date: Wed, 3 Sep 2025 11:46:46 +0200 Subject: [PATCH 5/8] Uncomment indices_chunk definition --- R/Start.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/Start.R b/R/Start.R index 53735ed7..c21c5f24 100644 --- a/R/Start.R +++ b/R/Start.R @@ -2752,7 +2752,7 @@ Start <- function(..., # dim = indices/selectors, # The inner dim selector is an array in which have file dim (e.g., time = [sdate = 2, time = 4], # or the inner dim doesn't go across any file dim (e.g., no time_across = 'sdate') - # indices_chunk <- c() + indices_chunk <- c() if ((!is.null(crossed_file_dim) & (any(crossed_file_dim %in% names(selector_file_dims)))) || is.null(crossed_file_dim)) { if (length(sub_array_of_selectors) > 0) { if (debug) { -- GitLab From dbed64b9f9c9fa42f21ed3be2419b1d2839b8eb8 Mon Sep 17 00:00:00 2001 From: vagudets Date: Wed, 3 Sep 2025 14:25:42 +0200 Subject: [PATCH 6/8] Fix pipeline? --- R/Start.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/Start.R b/R/Start.R index c21c5f24..0ee9622e 100644 --- a/R/Start.R +++ b/R/Start.R @@ -2752,7 +2752,6 @@ Start <- function(..., # dim = indices/selectors, # The inner dim selector is an array in which have file dim (e.g., time = [sdate = 2, time = 4], # or the inner dim doesn't go across any file dim (e.g., no time_across = 'sdate') - indices_chunk <- c() if ((!is.null(crossed_file_dim) & (any(crossed_file_dim %in% names(selector_file_dims)))) || is.null(crossed_file_dim)) { if (length(sub_array_of_selectors) > 0) { if (debug) { @@ -3923,6 +3922,7 @@ Start <- function(..., # dim = indices/selectors, # If merge_across_dims_narm = TRUE, add additional lines to remove these NAs. # TODO: Now it assumes that only one '_across'. Add a for loop for more-than-one case. if (merge_across_dims & (split_multiselected_dims | merge_across_dims_narm)) { + indices_chunk <- c() if (!merge_across_dims_narm) { data_array_tmp <- array(bigmemory::as.matrix(data_array), dim = final_dims) tmp <- match(names(final_dims), names(dims_of_merge_dim)) -- GitLab From bdc89d05c3e7265be5f3b8225bc31ed160127a2c Mon Sep 17 00:00:00 2001 From: vagudets Date: Tue, 9 Sep 2025 16:07:57 +0200 Subject: [PATCH 7/8] Fix issue --- R/Start.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/Start.R b/R/Start.R index 0ee9622e..695531c8 100644 --- a/R/Start.R +++ b/R/Start.R @@ -2753,6 +2753,7 @@ Start <- function(..., # dim = indices/selectors, # The inner dim selector is an array in which have file dim (e.g., time = [sdate = 2, time = 4], # or the inner dim doesn't go across any file dim (e.g., no time_across = 'sdate') if ((!is.null(crossed_file_dim) & (any(crossed_file_dim %in% names(selector_file_dims)))) || is.null(crossed_file_dim)) { + indices_chunk <- c() if (length(sub_array_of_selectors) > 0) { if (debug) { if (inner_dim %in% dims_to_check) { @@ -3922,7 +3923,6 @@ Start <- function(..., # dim = indices/selectors, # If merge_across_dims_narm = TRUE, add additional lines to remove these NAs. # TODO: Now it assumes that only one '_across'. Add a for loop for more-than-one case. if (merge_across_dims & (split_multiselected_dims | merge_across_dims_narm)) { - indices_chunk <- c() if (!merge_across_dims_narm) { data_array_tmp <- array(bigmemory::as.matrix(data_array), dim = final_dims) tmp <- match(names(final_dims), names(dims_of_merge_dim)) @@ -3952,6 +3952,9 @@ Start <- function(..., # dim = indices/selectors, #NOTE: When one file contains values for dicrete dimensions, rearrange the # chunks (i.e., work_piece) is necessary. if (split_multiselected_dims) { + if (is.null(indices_chunk)) { + indices_chunk <- c() + } tmp <- rebuild_array_merge_split( data_array = data_array_tmp, metadata = metadata_tmp, indices_chunk, all_split_dims, final_dims_fake, across_inner_dim, length_inner_across_dim) @@ -4088,6 +4091,7 @@ Start <- function(..., # dim = indices/selectors, #NOTE: When one file contains values for dicrete dimensions, rearrange the # chunks (i.e., work_piece) is necessary. if (split_multiselected_dims) { + browser() tmp <- rebuild_array_merge_split( data_array = NULL, metadata = metadata_tmp, indices_chunk, all_split_dims, final_dims_fake, across_inner_dim, length_inner_across_dim) -- GitLab From b4c6853d9a8718cf8a65320740bc2a2eb894a37d Mon Sep 17 00:00:00 2001 From: vagudets Date: Wed, 10 Sep 2025 14:25:38 +0200 Subject: [PATCH 8/8] Fix pipeline (fr) --- R/Start.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/Start.R b/R/Start.R index 695531c8..55c16f95 100644 --- a/R/Start.R +++ b/R/Start.R @@ -2753,7 +2753,6 @@ Start <- function(..., # dim = indices/selectors, # The inner dim selector is an array in which have file dim (e.g., time = [sdate = 2, time = 4], # or the inner dim doesn't go across any file dim (e.g., no time_across = 'sdate') if ((!is.null(crossed_file_dim) & (any(crossed_file_dim %in% names(selector_file_dims)))) || is.null(crossed_file_dim)) { - indices_chunk <- c() if (length(sub_array_of_selectors) > 0) { if (debug) { if (inner_dim %in% dims_to_check) { @@ -3952,7 +3951,7 @@ Start <- function(..., # dim = indices/selectors, #NOTE: When one file contains values for dicrete dimensions, rearrange the # chunks (i.e., work_piece) is necessary. if (split_multiselected_dims) { - if (is.null(indices_chunk)) { + if (!exists("indices_chunk")) { indices_chunk <- c() } tmp <- rebuild_array_merge_split( @@ -4067,7 +4066,6 @@ Start <- function(..., # dim = indices/selectors, else { # if retrieve = FALSE, metadata still needs to reshape if (merge_across_dims & (split_multiselected_dims | merge_across_dims_narm)) { - indices_chunk <- c() if (!merge_across_dims_narm) { tmp <- match(names(final_dims), names(dims_of_merge_dim)) if (any(diff(tmp[!is.na(tmp)]) < 0)) { #need to reorder @@ -4091,7 +4089,9 @@ Start <- function(..., # dim = indices/selectors, #NOTE: When one file contains values for dicrete dimensions, rearrange the # chunks (i.e., work_piece) is necessary. if (split_multiselected_dims) { - browser() + if (!exists("indices_chunk")) { + indices_chunk <- c() + } tmp <- rebuild_array_merge_split( data_array = NULL, metadata = metadata_tmp, indices_chunk, all_split_dims, final_dims_fake, across_inner_dim, length_inner_across_dim) -- GitLab