From 15bd737a3f86b41f723f91ee87dcbaf821fbb32e Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Tue, 15 Nov 2022 09:30:21 +0100 Subject: [PATCH 1/2] Change R version of .gitlab-ci.yml --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4db1f22..0873a3f 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 - R CMD build --resave-data . - R CMD check --as-cran --no-manual --run-donttest CSIndicators_*.tar.gz - R -e 'covr::package_coverage()' -- GitLab From 648a955afcbb81f8cee9994c4cc843e9ea3ca614 Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Tue, 15 Nov 2022 09:49:35 +0100 Subject: [PATCH 2/2] Update tests with correct lonlat data from CSTools --- tests/testthat/test-AbsToProbs.R | 2 +- tests/testthat/test-AccumulationExceedingThreshold.R | 6 +++--- tests/testthat/test-QThreshold.R | 2 +- tests/testthat/test-Threshold.R | 2 +- tests/testthat/test-TotalSpellTimeExceedingThreshold.R | 2 +- tests/testthat/test-TotalTimeExceedingThreshold.R | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/testthat/test-AbsToProbs.R b/tests/testthat/test-AbsToProbs.R index 9ef6df2..2905cf3 100644 --- a/tests/testthat/test-AbsToProbs.R +++ b/tests/testthat/test-AbsToProbs.R @@ -14,7 +14,7 @@ test_that("Sanity checks", { test_that("Seasonal forecasts", { - exp <- CSTools::lonlat_data$exp$data[1,1:3,1:3,,1:5,1:5] + exp <- CSTools::lonlat_temp$exp$data[1,1:3,1:3,,1:5,1:5] exp_probs <- AbsToProbs(exp) expect_equal(dim(exp)[3:5], dim(exp_probs)[3:5]) expect_equal(round(exp_probs[,1,1,1,1]), c(1, 0, 1)) diff --git a/tests/testthat/test-AccumulationExceedingThreshold.R b/tests/testthat/test-AccumulationExceedingThreshold.R index 90056b9..a0ad194 100644 --- a/tests/testthat/test-AccumulationExceedingThreshold.R +++ b/tests/testthat/test-AccumulationExceedingThreshold.R @@ -55,7 +55,7 @@ test_that("Sanity checks", { test_that("Seasonal forecasts", { - exp <- CSTools::lonlat_data$exp + exp <- CSTools::lonlat_temp$exp exp$data <- exp$data[,1:4,1:2,,,] res <- CST_AccumulationExceedingThreshold(exp, threshold = 280) expect_equal(round(res$data[,2,2,2]), @@ -76,9 +76,9 @@ test_that("Seasonal forecasts", { GDD <- AccumulationExceedingThreshold(exp - 17, threshold = 0, dates = Dates, time_dim = 'ftime', start = list(1, 4), end = list(31, 10), na.rm = TRUE) expect_equal(round(GDD[,1,1,1]), - c(538, 372, 116, 525, 220, 330)) + c(538, 367, 116, 519, 219, 282)) expect_equal(dim(GDD), - c(member = 6, sdate = 3, lat =4, lon = 4)) + c(member = 6, sdate = 3, lat = 4, lon = 4)) expect_error(AccumulationExceedingThreshold(exp - 17, threshold = 0, dates = Dates, start = list(1, 4), end = list(31, 10)), "Could not find dimension 'time' in 1th object provided in 'data'.") expect_equal(all(is.na(AccumulationExceedingThreshold(exp - 17, threshold = 0, dates = Dates, time_dim = 'ftime',start = list(1, 4), end = list(31, 10)))), diff --git a/tests/testthat/test-QThreshold.R b/tests/testthat/test-QThreshold.R index 14fd5d1..708c00a 100644 --- a/tests/testthat/test-QThreshold.R +++ b/tests/testthat/test-QThreshold.R @@ -58,7 +58,7 @@ test_that("Sanity checks", { test_that("Seasonal forecasts", { - obs <- CSTools::lonlat_data$obs$data - 248 + obs <- CSTools::lonlat_temp$obs$data - 248 obs_percentile <- QThreshold(obs, threshold = 35) expect_equal(dim(obs)[4:6], dim(obs_percentile)[4:6]) expect_equal(obs_percentile[, 1, 1, 3, 20, 53], c(rep(0.4, 4), rep(0.2, 2))) diff --git a/tests/testthat/test-Threshold.R b/tests/testthat/test-Threshold.R index 44f1291..7ff0ec9 100644 --- a/tests/testthat/test-Threshold.R +++ b/tests/testthat/test-Threshold.R @@ -38,7 +38,7 @@ test_that("Sanity checks", { test_that("Seasonal forecasts", { - exp <- CSTools::lonlat_data$exp$data + exp <- CSTools::lonlat_temp$exp$data thresholdP <- Threshold(exp, threshold = 0.9) expect_equal(dim(exp)[4:6], dim(thresholdP)[2:4]) expect_equal(round(thresholdP[1, , 2, 2]), c(283, 281, 280)) diff --git a/tests/testthat/test-TotalSpellTimeExceedingThreshold.R b/tests/testthat/test-TotalSpellTimeExceedingThreshold.R index e09fb15..4c55098 100644 --- a/tests/testthat/test-TotalSpellTimeExceedingThreshold.R +++ b/tests/testthat/test-TotalSpellTimeExceedingThreshold.R @@ -38,7 +38,7 @@ test_that("Sanity checks", { test_that("Seasonal Forecasts", { - exp <- CSTools::lonlat_data$exp + exp <- CSTools::lonlat_temp$exp exp$data <- exp$data[1,1:3,1:3,,,] res <- CST_TotalSpellTimeExceedingThreshold(exp, threshold = 260, spell = 2) expect_equal(res$data[,,1,1], diff --git a/tests/testthat/test-TotalTimeExceedingThreshold.R b/tests/testthat/test-TotalTimeExceedingThreshold.R index 408764b..a1104b4 100644 --- a/tests/testthat/test-TotalTimeExceedingThreshold.R +++ b/tests/testthat/test-TotalTimeExceedingThreshold.R @@ -57,12 +57,12 @@ test_that("Sanity checks", { test_that("Seasonal forecasts", { # compare with scalar fixed threshold - exp <- CSTools::lonlat_data$exp + exp <- CSTools::lonlat_temp$exp exp$data <- exp$data[1,1:3,,,,] - 247 SU35_NoP <- CST_TotalTimeExceedingThreshold(exp, threshold = 35)$data expect_equal(SU35_NoP[1,,15,3], c(0,1,1,1,0,0)) # convert to percentile - obs <- CSTools::lonlat_data$obs + obs <- CSTools::lonlat_temp$obs exp_percentile <- AbsToProbs(exp$data) obs_percentile <- drop(QThreshold(obs$data, threshold = 35)) data <- exp -- GitLab