Skip to content

Commit

Permalink
Merge pull request #423 from fbenke-pik/master
Browse files Browse the repository at this point in the history
enhance tests
  • Loading branch information
fbenke-pik authored Dec 20, 2024
2 parents badb9a2 + 9456703 commit e526353
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '8070552'
ValidationKey: '8091031'
AutocreateReadme: yes
allowLinterWarnings: no
AddInReadme: tutorial.md
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre")),
person("Oliver", "Richters", role = "aut")
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -118,17 +118,17 @@ In case of questions / problems please contact Falk Benke <[email protected]>

To cite package **piamInterfaces** in publications use:

Benke F, Richters O (2024). "piamInterfaces: Project specific interfaces to REMIND / MAgPIE." Version: 0.40.2, <https://github.com/pik-piam/piamInterfaces>.
Benke F, Richters O (2024). "piamInterfaces: Project specific interfaces to REMIND / MAgPIE." Version: 0.40.3, <https://github.com/pik-piam/piamInterfaces>.

A BibTeX entry for LaTeX users is

```latex
@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},
}
```
9 changes: 0 additions & 9 deletions inst/summations/summation_groups_ScenarioMIP.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions tests/testthat/test-checkSummations.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
22 changes: 22 additions & 0 deletions tests/testthat/test-generateIIASASubmission.R
Original file line number Diff line number Diff line change
Expand Up @@ -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_true(all(seq(2005, 2020, 1) %in% unique(result$period)))
expect_true(max(result$period) == 2020)

})

# Unit test to ensure functionality of weighted
# averages in the mapping. Generates a mapping file with
Expand Down

0 comments on commit e526353

Please sign in to comment.