From c741cdc86cb39bfb1965899344fc7c3ad35cea96 Mon Sep 17 00:00:00 2001 From: aho Date: Thu, 10 Nov 2022 09:57:20 +0100 Subject: [PATCH 1/2] Fix another Subset bug --- R/Start.R | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/R/Start.R b/R/Start.R index 964d52f..1eecc2c 100644 --- a/R/Start.R +++ b/R/Start.R @@ -2697,8 +2697,13 @@ Start <- function(..., # dim = indices/selectors, } else { if (length(names(var_file_dims)) > 0) { var_indices_to_take <- selector_indices_to_take[which(names(selector_indices_to_take) %in% names(var_file_dims))] - sub_array_of_values <- Subset(var_with_selectors, names(var_indices_to_take), - as.list(var_indices_to_take), drop = 'selected') + #TODO: Check TODO above. + if (!is.null(names(var_indices_to_take))) { + sub_array_of_values <- Subset(var_with_selectors, names(var_indices_to_take), + as.list(var_indices_to_take), drop = 'selected') + } else { + sub_array_of_values <- var_with_selectors + } } else { sub_array_of_values <- var_with_selectors } -- GitLab From 52ec78192eff5787c381d97a7d2437d6cc1fa6d3 Mon Sep 17 00:00:00 2001 From: aho Date: Mon, 14 Nov 2022 13:27:41 +0100 Subject: [PATCH 2/2] Add comment --- R/Start.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/Start.R b/R/Start.R index 1eecc2c..1251634 100644 --- a/R/Start.R +++ b/R/Start.R @@ -2670,9 +2670,8 @@ Start <- function(..., # dim = indices/selectors, selector_indices_to_take <- which(selector_file_dim_array == j, arr.ind = TRUE)[1, ] names(selector_indices_to_take) <- names(selector_file_dims) selector_store_position[names(selector_indices_to_take)] <- selector_indices_to_take - #TODO: Check if the non-subset part makes sense. "selector_indices_to_take" is an array if - # "selector_file_dims" is not 1 (if selector is an array with a file_dim dimname, ie., - # time = [sdate = 2, time = 4]. + # "selector_indices_to_take" is an array if "selector_file_dims" is not 1 (if + # selector is an array with a file_dim dimname, i.e., time = [sdate = 2, time = 4]. if (!is.null(names(selector_indices_to_take))) { sub_array_of_selectors <- Subset(selector_array, names(selector_indices_to_take), as.list(selector_indices_to_take), drop = 'selected') @@ -2697,11 +2696,12 @@ Start <- function(..., # dim = indices/selectors, } else { if (length(names(var_file_dims)) > 0) { var_indices_to_take <- selector_indices_to_take[which(names(selector_indices_to_take) %in% names(var_file_dims))] - #TODO: Check TODO above. if (!is.null(names(var_indices_to_take))) { sub_array_of_values <- Subset(var_with_selectors, names(var_indices_to_take), as.list(var_indices_to_take), drop = 'selected') } else { + # time across some file dim (e.g., "file_date") but doesn't have + # this file dim as dimension (e.g., time: [sdate, time]) sub_array_of_values <- var_with_selectors } } else { -- GitLab