From c21bfdfb701533dd510c75b48ee83ff383884615 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Fri, 20 Dec 2024 12:03:09 +0100 Subject: [PATCH 1/3] add interpolation test --- tests/testthat/test-generateIIASASubmission.R | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/testthat/test-generateIIASASubmission.R b/tests/testthat/test-generateIIASASubmission.R index 9d3c9f8f5..7d787617d 100644 --- a/tests/testthat/test-generateIIASASubmission.R +++ b/tests/testthat/test-generateIIASASubmission.R @@ -96,6 +96,28 @@ test_that("fail on duplicated data", { "Duplicated data found") }) +test_that("interpolation for ScenarioMIP works as expected", { + + # this test assumes that Emi|BC is one of the variables that should + # be interpolated as per the ScenarioMIP template + + data <- data.frame( + variable = "Emi|BC", unit = "Mt BC/yr", + model = "REMIND", scenario = "default", region = "GLO", + period = c(2005, 2010, 2020), + value = c(1, 10, 15) + ) + + result <- generateIIASASubmission( + mifs = data, + mapping = "ScenarioMIP", + outputFilename = NULL + ) + + expect_that(all(seq(2005, 2020, 1) %in% unique(result$period)), condition = TRUE) + expect_that(max(result$period) == 2020, condition = TRUE) + +}) # Unit test to ensure functionality of weighted # averages in the mapping. Generates a mapping file with From 728e65e6eeb53648ef53df02ea808ff2a98e8f44 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Fri, 20 Dec 2024 12:33:25 +0100 Subject: [PATCH 2/3] adjust summation test to avoid dummy entries in summation files --- inst/summations/summation_groups_ScenarioMIP.csv | 9 --------- tests/testthat/test-checkSummations.R | 16 ++++++++++++++++ tests/testthat/test-generateIIASASubmission.R | 4 ++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/inst/summations/summation_groups_ScenarioMIP.csv b/inst/summations/summation_groups_ScenarioMIP.csv index 802c39997..b3630d7a2 100644 --- a/inst/summations/summation_groups_ScenarioMIP.csv +++ b/inst/summations/summation_groups_ScenarioMIP.csv @@ -189,12 +189,3 @@ Emissions|VOC;Emissions|VOC|AFOLU|Land|Fires|Grassland Burning;1 Emissions|VOC;Emissions|VOC|AFOLU|Land|Fires|Peat Burning;1 Emissions|VOC;Emissions|VOC|AFOLU|Land|Wetlands;1 Emissions|VOC;Emissions|VOC|Waste;1 -;; -# Dummy, needs to be present for tests -Final Energy|Industry;Final Energy|Industry|Electricity;1 -Final Energy|Industry;Final Energy|Industry|Gases;1 -Final Energy|Industry;Final Energy|Industry|Heat;1 -Final Energy|Industry;Final Energy|Industry|Hydrogen;1 -Final Energy|Industry;Final Energy|Industry|Liquids;1 -Final Energy|Industry;Final Energy|Industry|Other;1 -Final Energy|Industry;Final Energy|Industry|Solids;1 diff --git a/tests/testthat/test-checkSummations.R b/tests/testthat/test-checkSummations.R index 399759e9c..6e0b624c1 100644 --- a/tests/testthat/test-checkSummations.R +++ b/tests/testthat/test-checkSummations.R @@ -19,6 +19,14 @@ test_that("checkSummations works", { for (summationFile in names(summationsNames())) { + + # The current test expects a summation including 'Final Energy|Industry' in the summation + # file to work. Skip summation file if this requirement is not met. + sf <- getSummations(summationFile) + if (!"Final Energy|Industry" %in% sf$parent) { + next + } + test_that(paste("test summationFile without errors using", summationFile), { if (summationFile == "AR6") { expect_message(tmp <- checkSummations(data, logFile = NULL, @@ -43,6 +51,14 @@ test_that("checkSummations works", { } }) test_that(paste("test summationFile with errors using", summationFile), { + + # The current test expects a summation including Final Energy|Industry in the summation + # file to work. Skip it if this requirement is not met for a summation file. + sf <- getSummations(summationFile) + if (!"Final Energy|Industry" %in% sf$parent) { + next + } + if (summationFile == "AR6") { expect_message(tmp <- checkSummations(mifFile = dataerror, logFile = NULL, template = summationFile, summationsFile = summationFile, diff --git a/tests/testthat/test-generateIIASASubmission.R b/tests/testthat/test-generateIIASASubmission.R index 7d787617d..851c922f9 100644 --- a/tests/testthat/test-generateIIASASubmission.R +++ b/tests/testthat/test-generateIIASASubmission.R @@ -114,8 +114,8 @@ test_that("interpolation for ScenarioMIP works as expected", { outputFilename = NULL ) - expect_that(all(seq(2005, 2020, 1) %in% unique(result$period)), condition = TRUE) - expect_that(max(result$period) == 2020, condition = TRUE) + expect_true(all(seq(2005, 2020, 1) %in% unique(result$period))) + expect_true(max(result$period) == 2020) }) From 94567031a9d7fe1430624a432c3d6c73df22a5d8 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Fri, 20 Dec 2024 12:38:19 +0100 Subject: [PATCH 3/3] increment version --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- README.md | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 40e0cbcf9..729b407eb 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '8070552' +ValidationKey: '8091031' AutocreateReadme: yes allowLinterWarnings: no AddInReadme: tutorial.md diff --git a/CITATION.cff b/CITATION.cff index 8e2338a8a..785e5a095 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'piamInterfaces: Project specific interfaces to REMIND / MAgPIE' -version: 0.40.2 -date-released: '2024-12-19' +version: 0.40.3 +date-released: '2024-12-20' abstract: Project specific interfaces to REMIND / MAgPIE. authors: - family-names: Benke diff --git a/DESCRIPTION b/DESCRIPTION index 82ab66e35..d4b2d0d55 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: piamInterfaces Title: Project specific interfaces to REMIND / MAgPIE -Version: 0.40.2 -Date: 2024-12-19 +Version: 0.40.3 +Date: 2024-12-20 Authors@R: c( person("Falk", "Benke", , "benke@pik-potsdam.de", role = c("aut", "cre")), person("Oliver", "Richters", role = "aut") diff --git a/README.md b/README.md index 8460b3984..3056cbb48 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Project specific interfaces to REMIND / MAgPIE -R package **piamInterfaces**, version **0.40.2** +R package **piamInterfaces**, version **0.40.3** [![CRAN status](https://www.r-pkg.org/badges/version/piamInterfaces)](https://cran.r-project.org/package=piamInterfaces) [![R build status](https://github.com/pik-piam/piamInterfaces/workflows/check/badge.svg)](https://github.com/pik-piam/piamInterfaces/actions) [![codecov](https://codecov.io/gh/pik-piam/piamInterfaces/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/piamInterfaces) [![r-universe](https://pik-piam.r-universe.dev/badges/piamInterfaces)](https://pik-piam.r-universe.dev/builds) @@ -118,7 +118,7 @@ In case of questions / problems please contact Falk Benke To cite package **piamInterfaces** in publications use: -Benke F, Richters O (2024). "piamInterfaces: Project specific interfaces to REMIND / MAgPIE." Version: 0.40.2, . +Benke F, Richters O (2024). "piamInterfaces: Project specific interfaces to REMIND / MAgPIE." Version: 0.40.3, . A BibTeX entry for LaTeX users is @@ -126,9 +126,9 @@ A BibTeX entry for LaTeX users is @Misc{, title = {piamInterfaces: Project specific interfaces to REMIND / MAgPIE}, author = {Falk Benke and Oliver Richters}, - date = {2024-12-19}, + date = {2024-12-20}, year = {2024}, url = {https://github.com/pik-piam/piamInterfaces}, - note = {Version: 0.40.2}, + note = {Version: 0.40.3}, } ```