diff --git a/.Rbuildignore b/.Rbuildignore index 6008b579d5dd55cd0c61aa4e05404c8437d91f3f..4212858235c6fea27a834c5e1a0012856a4ec6c9 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -10,7 +10,7 @@ README\.md$ vignettes .gitlab-ci.yml # unit tests should be ignored when building the package for CRAN -^tests$ +#^tests$ # CDO is not in windbuilder, so we can test the unit tests by winbuilder # but test-CDORemap.R and test-Load.R needs to be hidden #tests/testthat/test-CDORemap.R diff --git a/R/Trend.R b/R/Trend.R index 1f714a6fac3b87e9c2796afcbfde6d3d4cb42fc7..d709101a681eec1bab3104081bb184356d2fd0ba 100644 --- a/R/Trend.R +++ b/R/Trend.R @@ -50,7 +50,9 @@ #' \code{conf = TRUE}. #'} #'\item{$p.val}{ -#' The p-value calculated by anova(). Only present if \code{pval = TRUE}. +#' A numeric array of p-value calculated by anova(). The first dimension +#' 'stats' is 1, followed by the same dimensions as parameter 'data' except +#' the 'time_dim' dimension. Only present if \code{pval = TRUE}. #'} #'\item{$detrended}{ #' A numeric array with the same dimensions as paramter 'data', containing the @@ -188,7 +190,7 @@ Trend <- function(data, time_dim = 'ftime', interval = 1, polydeg = 1, } if (pval) { - p.val <- rep(NA, polydeg + 1) + p.val <- as.array(NA) } } diff --git a/man/Trend.Rd b/man/Trend.Rd index d283ee652d6795f127c6853e5dfa52e9715ce2e9..7623c3613149b891a5bf83c26bb32fb56716c541 100644 --- a/man/Trend.Rd +++ b/man/Trend.Rd @@ -66,7 +66,9 @@ A list containing: \code{conf = TRUE}. } \item{$p.val}{ - The p-value calculated by anova(). Only present if \code{pval = TRUE}. + A numeric array of p-value calculated by anova(). The first dimension + 'stats' is 1, followed by the same dimensions as parameter 'data' except + the 'time_dim' dimension. Only present if \code{pval = TRUE}. } \item{$detrended}{ A numeric array with the same dimensions as paramter 'data', containing the diff --git a/tests/testthat/test-Trend.R b/tests/testthat/test-Trend.R index 49a998229f5ca9336bb5a7c06c1eb8144922411e..07da6ce45c6b687c8e0ef9a7f746be1794d83b50 100644 --- a/tests/testthat/test-Trend.R +++ b/tests/testthat/test-Trend.R @@ -112,6 +112,22 @@ test_that("2. Output checks: dat1", { 0.1153846, tolerance = 0.001 ) + expect_equal( + dim(Trend(dat1)$trend), + c(stats = 2, dat = 1, sdate = 2) + ) + expect_equal( + dim(Trend(dat1)$p), + c(stats = 1, dat = 1, sdate = 2) + ) + expect_equal( + dim(Trend(dat1)$detrend), + c(ftime = 13, dat = 1, sdate = 2) + ) + expect_equal( + dim(Trend(dat1, polydeg = 3)$trend), + c(stats = 4, dat = 1, sdate = 2) + ) }) @@ -176,8 +192,32 @@ test_that("5. Output checks: dat4", { as.numeric(rep(NA, 5)) ) expect_equal( - Trend(dat4)$p.val[, 1, 1, 1], - c(NA, 0.01800594), - tolerance = 0.0001 + dim(Trend(dat4)$p.val), + c(stats = 1, lat = 2, lon = 3, lev = 2) + ) + expect_equal( + is.na(Trend(dat4)$p.val[, 1, 1, 1]), + TRUE ) + expect_equal( + as.vector(Trend(dat4)$trend[1, 2, , ]), + as.vector(Trend(dat3)$trend[1, 2, , ]) + ) + expect_equal( + as.vector(Trend(dat4)$p.val[1, 2, , ]), + as.vector(Trend(dat3)$p.val[1, 2, , ]) + ) + expect_equal( + as.vector(Trend(dat4)$conf.l[1, 2, , ]), + as.vector(Trend(dat3)$conf.l[1, 2, , ]) + ) + expect_equal( + as.vector(Trend(dat4)$conf.u[1, 2, , ]), + as.vector(Trend(dat3)$conf.u[1, 2, , ]) + ) + expect_equal( + as.vector(Trend(dat4)$de[1, 2, , ]), + as.vector(Trend(dat3)$de[1, 2, , ]) + ) + })