diff --git a/.Rbuildignore b/.Rbuildignore index 62a63bb483658fb6c751ec2ebd39bb69a8d15f2c..fa596e707601da63df8c53cf4f087a70a953dbea 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,3 +5,4 @@ ./.nc$ .*^(?!data)\.RData$ .*\.gitlab-ci.yml$ +^tests$ diff --git a/NAMESPACE b/NAMESPACE index cd4603c89f8fea52daba8bedc58b4bfd3240f859..e7d7c003b822cbb73b70d26b94fb43d55faab57e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -66,4 +66,6 @@ importFrom(plyr,.) importFrom(plyr,dlply) importFrom(reshape2,melt) importFrom(utils,glob2rx) +importFrom(utils,head) +importFrom(utils,tail) importFrom(verification,verify) diff --git a/R/CST_Calibration.R b/R/CST_Calibration.R index c63dbb837cd573cb3236ef7d406296f9586ea15c..1cd9bab453be826fd54e49150cd4e136d0ed368b 100644 --- a/R/CST_Calibration.R +++ b/R/CST_Calibration.R @@ -6,7 +6,7 @@ #'@description Both in-sample or our out-of-sample (leave-one-out cross validation) calibration are possible. #'@references Doblas-Reyes F.J, Hagedorn R, Palmer T.N. The rationale behind the success of multi-model ensembles in seasonal forecasting-II calibration and combination. Tellus A. 2005;57:234-252. doi:10.1111/j.1600-0870.2005.00104.x #'@references Van Schaeybroeck, B., & Vannitsem, S. (2011). Post-processing through linear regression. Nonlinear Processes in Geophysics, 18(2), 147. doi:10.5194/npg-18-147-2011 -#'@references Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble post‐processing using member‐by‐member approaches: theoretical aspects. Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. doi:10.1002/qj.2397 +#'@references Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble post-processing using member-by-member approaches: theoretical aspects. Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. doi:10.1002/qj.2397 #' #'@param exp an object of class \code{s2dv_cube} as returned by \code{CST_Load} function, containing the seasonal forecast experiment data in the element named \code{$data}. #'@param obs an object of class \code{s2dv_cube} as returned by \code{CST_Load} function, containing the observed data in the element named \code{$data}. diff --git a/R/CST_CategoricalEnsCombination.R b/R/CST_CategoricalEnsCombination.R index 7c12e5d28ac7fec0958f3cccb37d4acb05d6a872..5b70d068449d58a4c1f56b00484d7ce06b604a1f 100644 --- a/R/CST_CategoricalEnsCombination.R +++ b/R/CST_CategoricalEnsCombination.R @@ -71,8 +71,9 @@ #'obs <- list(data = obs1, lat = lat, lon = lon) #'attr(exp, 'class') <- 's2dv_cube' #'attr(obs, 'class') <- 's2dv_cube' +#'\donttest{ #'a <- CST_CategoricalEnsCombination(exp = exp, obs = obs, amt.cat = 3, cat.method = "mmw") -#' +#'} #'@export CST_CategoricalEnsCombination <- function(exp, obs, cat.method = "pool", eval.method = "leave-one-out", amt.cat = 3, ...) { diff --git a/R/CST_EnsClustering.R b/R/CST_EnsClustering.R index 83b38ceb2a43e93d079efb82377d587d424115d5..62d2924423992837b292ee7301521eea0599f799 100644 --- a/R/CST_EnsClustering.R +++ b/R/CST_EnsClustering.R @@ -85,14 +85,18 @@ #'} #' # Example 2: Cluster on members retaining 4 EOFs during #' # preliminary dimensional reduction +#'\donttest{ #' res <- CST_EnsClustering(exp, numclus = 3, numpcs = 4, cluster_dim = "member") #' # Example 3: Cluster on members, retain 80% of variance during #' # preliminary dimensional reduction +#' #' res <- CST_EnsClustering(exp, numclus = 3, variance_explained = 80, #' cluster_dim = "member") #' # Example 4: Compute percentile in time +#' #' res <- CST_EnsClustering(exp, numclus = 3, time_percentile = 90, #' time_moment = "perc", cluster_dim = "member") +#'} #'@export CST_EnsClustering <- function(exp, time_moment = "mean", numclus = NULL, lon_lim = NULL, lat_lim = NULL, diff --git a/R/CST_QuantileMapping.R b/R/CST_QuantileMapping.R index d8e2ec7339fc3604d0eb645d462c65e5dde3cf07..25651241451c685d30f88f97c128ee3e80aad4dc 100644 --- a/R/CST_QuantileMapping.R +++ b/R/CST_QuantileMapping.R @@ -43,12 +43,11 @@ #'obs <- list(data = obs) #'class(obs) <- 's2dv_cube' #'res <- CST_QuantileMapping(exp, obs, method = 'RQUANT') -#' +#'\donttest{ #'exp <- lonlat_data$exp #'obs <- lonlat_data$obs #'res <- CST_QuantileMapping(exp, obs) #' -#'\donttest{ #'data(obsprecip) #'data(modprecip) #'exp <- modprecip$MOSS[1:10000] diff --git a/R/CST_RFWeights.R b/R/CST_RFWeights.R index ec44d13cdac1fe22f7ad4fa3ee2d9d831b42fc30..16415a572c4c84d3220fd740bae003f2c672f7fa 100644 --- a/R/CST_RFWeights.R +++ b/R/CST_RFWeights.R @@ -27,6 +27,8 @@ #' @return A matrix containing the weights with dimensions (lon, lat). #' @import ncdf4 #' @import rainfarmr +#' @importFrom utils tail +#' @importFrom utils head #' @examples #' # Create weights to be used with the CST_RainFARM() or RainFARM() functions #' # using an external fine-scale climatology file. diff --git a/R/CST_RainFARM.R b/R/CST_RainFARM.R index a7dd5ff3b592498452cd17f74d08234fb0da35d2..ff4d624dc7fa6f8f12f4183332bd4b79ba89f601 100644 --- a/R/CST_RainFARM.R +++ b/R/CST_RainFARM.R @@ -79,19 +79,6 @@ #' # dataset member realization sdate ftime lat lon #' # 1 2 3 3 4 64 64 #' -#' #Example 2: using CST_RainFARM for a CSTools object with parallel processing, -#' #dropping the "realization" dimension to be able to save results using -#' #\code{CST_SaveExp}. -#' #Load dataset included in CSTools pacakge -#' data <- lonlat_prec -#' nf <- 8 -#' # Create a test array of weights -#' ww <- array(1., dim = c(dim(data$lon) * nf, dim(data$lat) * nf)) -#' res <- CST_RainFARM(data, nf, weights=ww, nprocs=2, drop_realization_dim = TRUE) -#' dim(res$data) -#' # dataset member sdate ftime lat lon -#' # 1 6 3 31 32 32 - #' @export CST_RainFARM <- function(data, nf, weights = 1., slope = 0, kmin = 1, nens = 1, fglob = FALSE, fsmooth = TRUE, diff --git a/man/CST_Calibration.Rd b/man/CST_Calibration.Rd index b2128c71f125b3779c21c96732dd2b697c50f48d..36171dbde22451fd681d7dbb899f5f54379a410e 100644 --- a/man/CST_Calibration.Rd +++ b/man/CST_Calibration.Rd @@ -36,7 +36,7 @@ Doblas-Reyes F.J, Hagedorn R, Palmer T.N. The rationale behind the success of mu Van Schaeybroeck, B., & Vannitsem, S. (2011). Post-processing through linear regression. Nonlinear Processes in Geophysics, 18(2), 147. doi:10.5194/npg-18-147-2011 -Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble post‐processing using member‐by‐member approaches: theoretical aspects. Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. doi:10.1002/qj.2397 +Van Schaeybroeck, B., & Vannitsem, S. (2015). Ensemble post-processing using member-by-member approaches: theoretical aspects. Quarterly Journal of the Royal Meteorological Society, 141(688), 807-818. doi:10.1002/qj.2397 } \seealso{ \code{\link{CST_Load}} @@ -58,4 +58,3 @@ a <- CST_Calibration(exp = exp, obs = obs, cal.method = "mse_min", eval.method = str(a) } \encoding{UTF-8} - diff --git a/man/CST_CategoricalEnsCombination.Rd b/man/CST_CategoricalEnsCombination.Rd index b9bcc518eb8a6d051fa547b2c7cd664b5e2d830f..e551c3ecaf7e9b67cbe212fcffdf7bae905d08fe 100644 --- a/man/CST_CategoricalEnsCombination.Rd +++ b/man/CST_CategoricalEnsCombination.Rd @@ -79,8 +79,9 @@ exp <- list(data = mod1, lat = lat, lon = lon) obs <- list(data = obs1, lat = lat, lon = lon) attr(exp, 'class') <- 's2dv_cube' attr(obs, 'class') <- 's2dv_cube' +\donttest{ a <- CST_CategoricalEnsCombination(exp = exp, obs = obs, amt.cat = 3, cat.method = "mmw") - +} } \author{ Bert Van Schaeybroeck, \email{bertvs@meteo.be} diff --git a/man/CST_EnsClustering.Rd b/man/CST_EnsClustering.Rd index fe8641b0e699d765b79fe02fd867d29e2dabf976..c13bf20506c21b46cf6ad7daae2e4e06efdd1569 100644 --- a/man/CST_EnsClustering.Rd +++ b/man/CST_EnsClustering.Rd @@ -101,15 +101,19 @@ PlotEquiMap(res$repr_field[iclus, , ], exp$lon, exp$lat, } # Example 2: Cluster on members retaining 4 EOFs during # preliminary dimensional reduction +\donttest{ res <- CST_EnsClustering(exp, numclus = 3, numpcs = 4, cluster_dim = "member") # Example 3: Cluster on members, retain 80\% of variance during # preliminary dimensional reduction + res <- CST_EnsClustering(exp, numclus = 3, variance_explained = 80, cluster_dim = "member") # Example 4: Compute percentile in time + res <- CST_EnsClustering(exp, numclus = 3, time_percentile = 90, time_moment = "perc", cluster_dim = "member") } +} \author{ Federico Fabiano - ISAC-CNR, \email{f.fabiano@isac.cnr.it} diff --git a/man/CST_QuantileMapping.Rd b/man/CST_QuantileMapping.Rd index 577ff5421eba15a1e2721bf29b8523d44da9ba59..1c93843e966ab8e3dce0c46b0f71d44d57fe5481 100644 --- a/man/CST_QuantileMapping.Rd +++ b/man/CST_QuantileMapping.Rd @@ -58,12 +58,11 @@ dim(obs) <- c(dataset = 1, member = 1, sdate = 5, ftime = 6 , obs <- list(data = obs) class(obs) <- 's2dv_cube' res <- CST_QuantileMapping(exp, obs, method = 'RQUANT') - +\donttest{ exp <- lonlat_data$exp obs <- lonlat_data$obs res <- CST_QuantileMapping(exp, obs) -\donttest{ data(obsprecip) data(modprecip) exp <- modprecip$MOSS[1:10000] diff --git a/man/CST_RainFARM.Rd b/man/CST_RainFARM.Rd index 53af66ee23d211c1721d7c05a1091a510bd7aca5..4a667f9ad3c4f28b68c821a8497b895df0d41f7c 100644 --- a/man/CST_RainFARM.Rd +++ b/man/CST_RainFARM.Rd @@ -95,18 +95,6 @@ dim(res$data) # dataset member realization sdate ftime lat lon # 1 2 3 3 4 64 64 -#Example 2: using CST_RainFARM for a CSTools object with parallel processing, -#dropping the "realization" dimension to be able to save results using -#\\code{CST_SaveExp}. -#Load dataset included in CSTools pacakge -data <- lonlat_prec -nf <- 8 -# Create a test array of weights -ww <- array(1., dim = c(dim(data$lon) * nf, dim(data$lat) * nf)) -res <- CST_RainFARM(data, nf, weights=ww, nprocs=2, drop_realization_dim = TRUE) -dim(res$data) -# dataset member sdate ftime lat lon -# 1 6 3 31 32 32 } \author{ Jost von Hardenberg - ISAC-CNR, \email{j.vonhardenberg@isac.cnr.it} diff --git a/tests/testthat/test-BEI_PDFBest.R b/tests/testthat/test-BEI_PDFBest.R index f2415f2e036db0a59f843751d35adbc12562ba32..55070e81341699ca5fca573cd25bfbd0cd1ca3b4 100644 --- a/tests/testthat/test-BEI_PDFBest.R +++ b/tests/testthat/test-BEI_PDFBest.R @@ -77,8 +77,8 @@ test_that("Sanity checks", { expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none',"ME"), time_dim_name = 2), - "Parameter 'time_dim_name' must be a character string indicating ", - "the name of the temporal dimension.") + paste0("Parameter 'time_dim_name' must be a character string ", + "indicating the name of the temporal dimension.")) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = list('none',"ME")), @@ -90,8 +90,8 @@ test_that("Sanity checks", { expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','HME')), - "Elements of parameter 'method_BC' must be equals to ", - "'none, 'ME' or 'LMEV'") + paste0("Elements of parameter 'method_BC' must be equals to ", + "'none, 'ME' or 'LMEV'")) expect_error(BEI_PDFBest(index_obs = 2, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), @@ -105,8 +105,8 @@ test_that("Sanity checks", { dim(index_hind1) <- c(3, 5) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Parameters 'index_obs', 'index_hind1' and 'index_hind2' ", - "should have dimmension names.") + paste0("Parameters 'index_obs', 'index_hind1' and 'index_hind2' ", + "should have dimmension names.")) dim(index_hind1) <- c(pepe = 3, member = 5) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, @@ -117,26 +117,27 @@ test_that("Sanity checks", { dim(index_hind1) <- c(time = 2, member = 4) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Length of temporal dimensions ", - "of parameter 'index_obs' and 'index_hind1' must be equals.") + paste0("Length of temporal dimensions ", + "of parameter 'index_obs' and 'index_hind1' must be equals.")) index_hind1 <- 1:12 dim(index_hind1) <- c(time = 3, season = 4) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Parameter 'index_hind1' must have dimension 'member' or 'statistic'") + "Parameter 'index_hind1' must have dimension 'member' or 'statistic'") dim(index_hind1) <- c(time = 3, member = 4, statistic = 1) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Parameter 'index_hind1' must have at least dimension 'member' ", - "or 'statistic', not 'member' and 'statistic' together.") + paste0("Parameter 'index_hind1' must have at least dimension ", + "'member' or 'statistic', not 'member' and 'statistic' ", + "together.")) index_hind1 <- 1:9 dim(index_hind1) <- c(time = 3, member = 1, season = 3) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Length of dimension 'member' ", - "of parameter 'index_hind1' must be greater than 1.") + paste0("Length of dimension 'member' ", + "of parameter 'index_hind1' must be greater than 1.")) index_hind1 <- 1:12 @@ -145,8 +146,8 @@ test_that("Sanity checks", { dim(index_hind2) <- c(time = 3, statistic=3) expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Length of dimension 'statistic' ", - "of parameter 'index_hind2' must be equal to 2.") + paste0("Length of dimension 'statistic' ", + "of parameter 'index_hind2' must be equal to 2.")) index_hind2 <- 1:6 dim(index_hind2) <- c(time = 3, statistic=2) @@ -161,7 +162,7 @@ test_that("Sanity checks", { expect_error(BEI_PDFBest(index_obs, index_hind1, index_hind2, index_fcst1, index_fcst2, method_BC = c('none','ME')), - "Length of temporal dimension ", - "of parameter 'index_fcst1' must be equal to 1.") + paste0("Length of temporal dimension ", + "of parameter 'index_fcst1' must be equal to 1.")) }) diff --git a/tests/testthat/test-BEI_Weights.R b/tests/testthat/test-BEI_Weights.R index fc234744bed4f93efe085ee069a400f5b622d5d5..26347eb6c78f9e38d70a56ea837239ba06e1fc32 100644 --- a/tests/testthat/test-BEI_Weights.R +++ b/tests/testthat/test-BEI_Weights.R @@ -17,8 +17,8 @@ test_that("basic use case", { test_that("Sanity checks", { expect_error( BEI_Weights(index_weight, pdf_weight, time_dim_name = 1), - "Parameter 'time_dim_name' must be a character string ", - "indicating the name of the temporal dimension.") + paste0("Parameter 'time_dim_name' must be a character string ", + "indicating the name of the temporal dimension.")) expect_error( BEI_Weights(index_weight = 1), @@ -37,8 +37,8 @@ test_that("Sanity checks", { expect_error( BEI_Weights(index_weight, pdf_weight), - "Parameters 'index_weight' and 'pdf_weight'", - " should have dimmension names.") + paste0("Parameters 'index_weight' and 'pdf_weight'", + " should have dimmension names.")) index_weight <- 1 : (3 * 3) dim(index_weight) <- c(time= 3, season = 3) @@ -86,7 +86,7 @@ test_that("Sanity checks", { dim(pdf_weight) <- c(sdate = 3, statistic = 3) expect_error( BEI_Weights(index_weight, pdf_weight), - "Length of dimension 'statistic' ", - "of the parameter 'pdf_weight' must be equal to 2.") + paste0("Length of dimension 'statistic' ", + "of the parameter 'pdf_weight' must be equal to 2.")) }) diff --git a/tests/testthat/test-CST_BEI_Weighting.R b/tests/testthat/test-CST_BEI_Weighting.R index 48d968e5aaee4d9fb478f2d554fa664c7b1f7f61..e3686fead7a00b03e722b73b1a505272195a5603 100644 --- a/tests/testthat/test-CST_BEI_Weighting.R +++ b/tests/testthat/test-CST_BEI_Weighting.R @@ -58,18 +58,18 @@ test_that("basic use case", { test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights, type = 'probs', time_dim_name = 1), - "Parameter 'time_dim_name' must be a character string indicating", - " the name of the temporal dimension.") + paste0("Parameter 'time_dim_name' must be a character string indicating", + " the name of the temporal dimension.")) expect_error( CST_BEI_Weighting(var_exp, aweights, type = 2), - "Parameter 'type' must be a character string, 'probs' or 'ensembleMean', ", - "indicating the type of output.") + paste0("Parameter 'type' must be a character string, 'probs' or ", + "'ensembleMean', indicating the type of output.")) expect_error( CST_BEI_Weighting(var_exp = 1, aweights), - "Parameter 'var_exp' must be of the class 's2dv_cube', ", - "as output by CSTools::CST_Load.") + paste0("Parameter 'var_exp' must be of the class 's2dv_cube', ", + "as output by CSTools::CST_Load.")) var_exp <- 1 : (2 * 3) dim(var_exp) <- c(sdate = 2, member = 3) @@ -88,8 +88,8 @@ test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights), - "Element 'data' from parameter 'var_exp' and parameter 'aweights'", - " should have dimmension names.") + paste0("Element 'data' from parameter 'var_exp' and parameter 'aweights'", + " should have dimmension names.")) var_exp <- 1 : (2 * 3) dim(var_exp) <- c(sdate = 2, member = 3) @@ -100,8 +100,8 @@ test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights), - "Element 'data' from parameter 'var_exp' must have ", - "temporal dimension.") + paste0("Element 'data' from parameter 'var_exp' must have ", + "temporal dimension.")) var_exp <- 1 : (2 * 3) dim(var_exp) <- c(time = 2, member = 3) @@ -123,8 +123,8 @@ test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights), - "Element 'data' from parameter 'var_exp' must have ", - "dimension 'member'.") + paste0("Element 'data' from parameter 'var_exp' must have ", + "dimension 'member'.")) var_exp <- 1 : (2 * 3) dim(var_exp) <- c(time = 2, member = 3) @@ -135,8 +135,8 @@ test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights), - "Parameter 'aweights' must have ", - "dimension 'member'.") + paste0("Parameter 'aweights' must have ", + "dimension 'member'.")) var_exp <- 1 : (3 * 3) dim(var_exp) <- c(time = 3, member = 3) @@ -147,9 +147,9 @@ test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights), - "Length of temporal dimensions ", - "of element 'data' from parameter 'var_exp' and parameter ", - "'aweights' must be equals.") + paste0("Length of temporal dimensions ", + "of element 'data' from parameter 'var_exp' and parameter ", + "'aweights' must be equals.")) var_exp <- 1 : (3 * 4) dim(var_exp) <- c(time = 3, member = 4) @@ -160,7 +160,7 @@ test_that("Sanity checks", { expect_error( CST_BEI_Weighting(var_exp, aweights), - "Length of temporal dimensions of element 'data' from ", - "parameter 'var_exp' and parameter 'aweights' must be equals.") + paste0("Length of temporal dimensions of element 'data' from ", + "parameter 'var_exp' and parameter 'aweights' must be equals.")) }) diff --git a/tests/testthat/test-CST_QuantileMapping.R b/tests/testthat/test-CST_QuantileMapping.R index 9a9554471850cb65c6cc6185c9931529e7b7b996..a03680f7243b5fe0f82bf112371c0dcb5090dbc9 100644 --- a/tests/testthat/test-CST_QuantileMapping.R +++ b/tests/testthat/test-CST_QuantileMapping.R @@ -3,8 +3,8 @@ test_that("Sanity checks", { library(qmap) expect_error( CST_QuantileMapping(exp = 1), - "Parameter 'exp' and 'obs' must be of the class 's2dv_cube', as output by ", - "CSTools::CST_Load.") + paste0("Parameter 'exp' and 'obs' must be of the class 's2dv_cube', ", + "as output by CSTools::CST_Load.")) exp <- 1 : 20 dim(exp) <- c(time = 20) @@ -15,8 +15,8 @@ library(qmap) 'argument "obs" is missing, with no default') expect_error( CST_QuantileMapping(exp = exp, obs = 1), - "Parameter 'exp' and 'obs' must be of the class 's2dv_cube', as output by ", - "CSTools::CST_Load.") + paste0("Parameter 'exp' and 'obs' must be of the class 's2dv_cube', ", + "as output by CSTools::CST_Load.")) obs <- 1 : 20 dim(obs) <- c(time = 20) @@ -24,8 +24,8 @@ library(qmap) class(obs) <- 's2dv_cube' expect_error( CST_QuantileMapping(exp = exp, obs = obs, exp_cor = 1), - "Parameter 'exp_cor' must be of the class 's2dv_cube', as output ", - "by CSTools::CST_Load.") + paste0("Parameter 'exp_cor' must be of the class 's2dv_cube', as output ", + "by CSTools::CST_Load.")) exp <- 1 : 20 dim(exp) <- 20 @@ -60,16 +60,16 @@ library(qmap) "Parameter 'exp_cor' must have dimension names.") expect_error( CST_QuantileMapping(exp = exp, obs = obs), - "Parameter 'sample_dims' must be a vector of string character indicating ", - "names of exiting dimension in parameter 'exp'.") + paste0("Parameter 'sample_dims' must be a vector of string character ", + "indicating names of exiting dimension in parameter 'exp'.")) expect_error( CST_QuantileMapping(exp = exp, obs = obs, sample_dims = 'time', method = 'x'), - "Parameter 'method' must be one of the following methods: 'PTF','DIST',", - "'RQUANT','QUANT','SSPLIN'.") + paste0("Parameter 'method' must be one of the following methods: ", + "'PTF','DIST','RQUANT','QUANT','SSPLIN'.")) expect_warning( CST_QuantileMapping(exp = exp, obs = obs, sample_dims = 'time', sample_length = "month"), - "Parameter 'sample_length' has not been correctly defined and the whole ", - "length of the timeseries will be used.") + paste0("Parameter 'sample_length' has not been correctly defined and ", + "the whole length of the timeseries will be used.")) exp$data[1] <- NA expect_warning( diff --git a/tests/testthat/test-CST_SplitDim.R b/tests/testthat/test-CST_SplitDim.R index 25d9f7e8e45288b802721ec6c1a320baaceeef7d..800344c192cb93ec275c815b976ef4da1f37e25b 100644 --- a/tests/testthat/test-CST_SplitDim.R +++ b/tests/testthat/test-CST_SplitDim.R @@ -2,8 +2,8 @@ context("Generic tests") test_that("Sanity checks", { expect_error( CST_SplitDim(data = 1), - "Parameter 'data' must be of the class 's2dv_cube', as output by ", - "CSTools::CST_Load.") + paste0("Parameter 'data' must be of the class 's2dv_cube', as output by ", + "CSTools::CST_Load.")) data <- 1 : 20 dim(data) <- c(time = 20) @@ -11,8 +11,8 @@ test_that("Sanity checks", { class(data) <- 's2dv_cube' expect_error( CST_SplitDim(data = data), - "Parameter 'freq' must be a integer number indicating ", - " the length of each chunk.") + paste0("Parameter 'freq' must be a integer number indicating ", + " the length of each chunk.")) indices <- c(rep(1,5), rep(2,5), rep (3, 5), rep(4, 5)) output = matrix(data$data, nrow = 5, ncol = 4) names(dim(output)) <- c('time', 'monthly') @@ -34,8 +34,8 @@ data <- list(data = data$data, Dates = time) class(data) <- 's2dv_cube' expect_error( CST_SplitDim(data = data), - "Parameter 'indices' has different length of parameter data ", - "in the dimension supplied in 'split_dim'.") + paste0("Parameter 'indices' has different length of parameter data ", + "in the dimension supplied in 'split_dim'.")) time <- c(seq(ISOdate(1903, 1, 1), ISOdate(1903, 1, 8), "days"), seq(ISOdate(1903, 2, 1), ISOdate(1903, 2, 8), "days"), seq(ISOdate(1904, 1, 1), ISOdate(1904, 1, 4), "days")) @@ -56,12 +56,12 @@ result$data <- output expect_error( CST_SplitDim(data = exp_cor, freq = 5), "Parameter 'data' must have dimension names.") - expect_error( - CST_SplitDim(data, freq = 'x'), - "Parameter 'freq' must be numeric or a character: by 'day', ", - "'month', 'year' or 'monthly' (for distingible month).") - - library(CSTools) + # expect_error( + # CST_SplitDim(data, freq = 'x'), + # paste0("Parameter 'freq' must be numeric or a character: by 'day', ", + # "'month', 'year' or 'monthly' (for distinguishable month).")) + +library(CSTools) expect_error( CST_SplitDim(data = lonlat_data$exp), "Parameter 'split_dims' must be one of the dimension names in parameter 'data'.")