Skip to content

Commit

Permalink
add tests for magpiemodel#35
Browse files Browse the repository at this point in the history
  • Loading branch information
orichters committed Nov 21, 2022
1 parent d5b6e6a commit e0c2961
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ValidationKey: '521478'
ValidationKey: '540876'
AutocreateReadme: yes
allowLinterWarnings: no
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "piamInterfaces: Project specific interfaces to REMIND / MAgPIE",
"version": "0.0.27",
"version": "0.0.28",
"description": "<p>Project specific interfaces to REMIND / MAgPIE.<\/p>",
"creators": [
{
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.0.27
Date: 2022-11-18
Version: 0.0.28
Date: 2022-11-21
Authors@R: c(
person("Falk", "Benke", , "benke@pik-potsdam.de", role = c("aut", "cre")),
person("Oliver", "Richters", role = "aut")
Expand Down
Binary file added R/.checkSummations.R.swp
Binary file not shown.
3 changes: 2 additions & 1 deletion R/checkSummations.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ checkSummations <- function(mifFile, outputDirectory = ".", template = "AR6", su
) %>%
select(-c("factor", "parent"))

text <- paste0("\n### Analyzing ", mifFile, ".\n# Use ", summationsFile, " to check if summation groups add up.")
text <- paste0("\n### Analyzing ", if (is.null(ncol(mifFile))) mifFile else "provided data",
".\n# Use ", summationsFile, " to check if summation groups add up.")

# write data to dataDumpFile
if (length(dataDumpFile) > 0) {
Expand Down
6 changes: 3 additions & 3 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.0.27**
R package **piamInterfaces**, version **0.0.28**

[![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/piam_interfaces/workflows/check/badge.svg)](https://github.com/pik-piam/piam_interfaces/actions) [![codecov](https://codecov.io/gh/pik-piam/piam_interfaces/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/piam_interfaces) [![r-universe](https://pik-piam.r-universe.dev/badges/piamInterfaces)](https://pik-piam.r-universe.dev/ui#builds)

Expand Down Expand Up @@ -38,7 +38,7 @@ In case of questions / problems please contact Falk Benke <benke@pik-potsdam.de>

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

Benke F, Richters O (2022). _piamInterfaces: Project specific interfaces to REMIND / MAgPIE_. R package version 0.0.27, <URL: https://github.com/pik-piam/piam_interfaces>.
Benke F, Richters O (2022). _piamInterfaces: Project specific interfaces to REMIND / MAgPIE_. R package version 0.0.28, <URL: https://github.com/pik-piam/piam_interfaces>.

A BibTeX entry for LaTeX users is

Expand All @@ -47,7 +47,7 @@ A BibTeX entry for LaTeX users is
title = {piamInterfaces: Project specific interfaces to REMIND / MAgPIE},
author = {Falk Benke and Oliver Richters},
year = {2022},
note = {R package version 0.0.27},
note = {R package version 0.0.28},
url = {https://github.com/pik-piam/piam_interfaces},
}
```
8 changes: 8 additions & 0 deletions tests/testthat/test-checkSummations.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ for (summationFile in names(summationsNames())) {
data <- magclass::add_dimension(data, dim = 3.1, add = "model", nm = "REMIND")
data <- magclass::add_dimension(data, dim = 3.1, add = "scenario", nm = "default")
magclass::write.report(data, file = file.path(tempdir(), "test.mif"), ndigit = 0)
expect_message(tmp <- checkSummations(data, logFile = NULL,
template = "AR6", summationsFile = summationFile, outputDirectory = tempdir(),
dataDumpFile = "checkSummations.csv"),
"All summation checks were fine")
expect_message(tmp <- checkSummations(mifFile = file.path(tempdir(), "test.mif"), logFile = NULL,
template = "AR6", summationsFile = summationFile, outputDirectory = tempdir(),
dataDumpFile = "checkSummations.csv"),
Expand All @@ -21,6 +25,10 @@ for (summationFile in names(summationsNames())) {
data <- magclass::add_dimension(data, dim = 3.1, add = "model", nm = "REMIND")
data <- magclass::add_dimension(data, dim = 3.1, add = "scenario", nm = "default")
magclass::write.report(data, file = file.path(tempdir(), "test.mif"), ndigit = 0)
expect_message(tmp <- checkSummations(mifFile = data, logFile = NULL,
template = "AR6", summationsFile = summationFile, outputDirectory = tempdir(),
dataDumpFile = "checkSummations.csv"),
"Final Energy")
expect_message(tmp <- checkSummations(mifFile = file.path(tempdir(), "test.mif"), logFile = NULL,
template = "AR6", summationsFile = summationFile, outputDirectory = tempdir(),
dataDumpFile = "checkSummations.csv"),
Expand Down

0 comments on commit e0c2961

Please sign in to comment.