diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef540fe63c5bdfb2b3ee3bfb3a3e9e6513f1b2a5..c7deb1af5aac18cff5d07efec0fc1b0949cabf83 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ stages: build: stage: build script: - - module load R/3.6.1-foss-2015a-bare + - module load R/4.1.2-foss-2015a-bare - module load CDO/1.9.8-foss-2015a - R CMD build --resave-data . - R CMD check --as-cran --no-manual --run-donttest startR_*.tar.gz diff --git a/R/Start.R b/R/Start.R index d9e9b095eb56cb16374d7c627d799dc74ce81af6..a6d3c02558e5e9f0ad8cf16dfe03808524a8e04e 100644 --- a/R/Start.R +++ b/R/Start.R @@ -1409,7 +1409,7 @@ Start <- function(..., # dim = indices/selectors, # Chunk it only if it is defined dim (i.e., list of character with names of depended dim) if (!(length(dat_selectors[[depending_dim_name]]) == 1 && dat_selectors[[depending_dim_name]] %in% c('all', 'first', 'last'))) { - if (sapply(dat_selectors[[depending_dim_name]], is.character)) { + if (any(sapply(dat_selectors[[depending_dim_name]], is.character))) { dat_selectors[[depending_dim_name]] <- dat_selectors[[depending_dim_name]][desired_chunk_indices] } diff --git a/R/zzz.R b/R/zzz.R index 6b6189b3c0697892ba35a3f78eecb0db42832343..0579b59d48a0dfe90761c8fe081625758fbf944f 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -566,7 +566,7 @@ generate_vars_to_transform <- function(vars_to_transform, picked_vars, transform # Turn indices to values for transform_crop_domain generate_transform_crop_domain_values <- function(transform_crop_domain, picked_vars) { - if (transform_crop_domain == 'all') { + if (any(transform_crop_domain == 'all')) { transform_crop_domain <- c(picked_vars[1], tail(picked_vars, 1)) } else { # indices() if (is.list(transform_crop_domain)) { diff --git a/tests/testthat/test-Start-indices_list_vector.R b/tests/testthat/test-Start-indices_list_vector.R index 0ad897a08b2e6b1677b3f85718e061a7284b5443..82e5cb1dc1183e3092460c59c6499549d925abd0 100644 --- a/tests/testthat/test-Start-indices_list_vector.R +++ b/tests/testthat/test-Start-indices_list_vector.R @@ -126,44 +126,18 @@ as.vector(exp2) # .. ..$ latitude : num [1:3(1d)] -81 -84.6 -88.2 -test_that("3. transform, indices reverse", { - -# lat and lon are lists of indices -suppressWarnings( -exp1 <- Start(dat = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc', - var = 'tas', - sdate = '20000101', - ensemble = indices(1), - time = indices(1), - latitude = indices(list(30, 1)), - latitude_reorder = Sort(), - longitude = indices(list(1, 40)), # can't reverse. Different meaning - longitude_reorder = CircularSort(0, 360), - transform = CDORemapper, - transform_params = list(grid = 'r100x50', - method = 'con', - crop = c(0, 11, -90, -81)), - transform_vars = c('latitude', 'longitude'), - transform_extra_cells = 8, - synonims = list(latitude = c('lat', 'latitude'), - longitude = c('longitude', 'lon')), - return_vars = list(latitude = NULL, - longitude = NULL, - time = 'sdate'), - retrieve= T) -) - -# This test is not valid because it doesn't make sense to use longitude = 40:1. With the automatic "crop" values, the result is not correct. -## lat and lon are vectors of indices +#test_that("3. transform, indices reverse", { +# +## lat and lon are lists of indices #suppressWarnings( -#exp2 <- Start(dat = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc', +#exp1 <- Start(dat = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc', # var = 'tas', # sdate = '20000101', # ensemble = indices(1), # time = indices(1), -# latitude = 30:1, +# latitude = indices(list(30, 1)), # latitude_reorder = Sort(), -# longitude = 40:1, +# longitude = indices(list(1, 40)), # can't reverse. Different meaning # longitude_reorder = CircularSort(0, 360), # transform = CDORemapper, # transform_params = list(grid = 'r100x50', @@ -179,12 +153,38 @@ exp1 <- Start(dat = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var # retrieve= T) #) # -#expect_equal( -#as.vector(drop(exp1)[, 4:1]), -#as.vector(exp2) -#) - -}) +## This test is not valid because it doesn't make sense to use longitude = 40:1. With the automatic "crop" values, the result is not correct. +### lat and lon are vectors of indices +##suppressWarnings( +##exp2 <- Start(dat = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc', +## var = 'tas', +## sdate = '20000101', +## ensemble = indices(1), +## time = indices(1), +## latitude = 30:1, +## latitude_reorder = Sort(), +## longitude = 40:1, +## longitude_reorder = CircularSort(0, 360), +## transform = CDORemapper, +## transform_params = list(grid = 'r100x50', +## method = 'con', +## crop = c(0, 11, -90, -81)), +## transform_vars = c('latitude', 'longitude'), +## transform_extra_cells = 8, +## synonims = list(latitude = c('lat', 'latitude'), +## longitude = c('longitude', 'lon')), +## return_vars = list(latitude = NULL, +## longitude = NULL, +## time = 'sdate'), +## retrieve= T) +##) +## +##expect_equal( +##as.vector(drop(exp1)[, 4:1]), +##as.vector(exp2) +##) +# +#}) ################################################################ ################################################################