diff --git a/.buildlibrary b/.buildlibrary index a79f51fa..259f2da2 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '7318728' +ValidationKey: '7342505' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/CITATION.cff b/CITATION.cff index 8020921d..148f046b 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: 'madrat: May All Data be Reproducible and Transparent (MADRaT) *' -version: 3.7.2 -date-released: '2023-11-13' +version: 3.7.3 +date-released: '2023-11-24' abstract: Provides a framework which should improve reproducibility and transparency in data processing. It provides functionality such as automatic meta data creation and management, rudimentary quality management, data caching, work-flow management diff --git a/DESCRIPTION b/DESCRIPTION index 30e62ccf..20cf2fd4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: madrat Title: May All Data be Reproducible and Transparent (MADRaT) * -Version: 3.7.2 -Date: 2023-11-13 +Version: 3.7.3 +Date: 2023-11-24 Authors@R: c( person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = c("aut", "cre")), person("Lavinia", "Baumstark", , "lavinia@pik-potsdam.de", role = "aut"), diff --git a/R/calcOutput.R b/R/calcOutput.R index fc7dfd11..14a2c2ac 100644 --- a/R/calcOutput.R +++ b/R/calcOutput.R @@ -298,9 +298,10 @@ calcOutput <- function(type, aggregate = TRUE, file = NULL, years = NULL, # noli if (x$class != "magpie") stop("years argument can only be used in combination with x$class=\"magpie\"!") # check that years exist in provided data if (!all(as.integer(sub("y", "", years)) %in% getYears(x$x, as.integer = TRUE))) { - stop("Some years are missing in the data provided by function ", functionname, "(", - paste(years[!(as.integer(sub("y", "", years)) %in% getYears(x$x, as.integer = TRUE))], collapse = ", "), - ")!") + warning("Some years are missing in the data provided by function ", functionname, "(", + paste(years[!(as.integer(sub("y", "", years)) %in% getYears(x$x, as.integer = TRUE))], + collapse = ", "), ")!") + years <- intersect(as.integer(sub("y", "", years)), getYears(x$x, as.integer = TRUE)) } x$x <- x$x[, years, ] if (!is.null(x$weight)) if (nyears(x$weight) > 1) x$weight <- x$weight[, years, ] diff --git a/README.md b/README.md index e76a81d2..388993bf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # May All Data be Reproducible and Transparent (MADRaT) * -R package **madrat**, version **3.7.2** +R package **madrat**, version **3.7.3** [![CRAN status](https://www.r-pkg.org/badges/version/madrat)](https://cran.r-project.org/package=madrat) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1115490.svg)](https://doi.org/10.5281/zenodo.1115490) [![R build status](https://github.com/pik-piam/madrat/workflows/check/badge.svg)](https://github.com/pik-piam/madrat/actions) [![codecov](https://codecov.io/gh/pik-piam/madrat/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/madrat) [![r-universe](https://pik-piam.r-universe.dev/badges/madrat)](https://pik-piam.r-universe.dev/builds) @@ -55,7 +55,7 @@ In case of questions / problems please contact Jan Philipp Dietrich . +Dietrich J, Baumstark L, Wirth S, Giannousakis A, Rodrigues R, Bodirsky B, Leip D, Kreidenweis U, Klein D, Sauer P (2023). _madrat: May All Data be Reproducible and Transparent (MADRaT)_. doi:10.5281/zenodo.1115490 , R package version 3.7.3, . A BibTeX entry for LaTeX users is @@ -64,7 +64,7 @@ A BibTeX entry for LaTeX users is title = {madrat: May All Data be Reproducible and Transparent (MADRaT)}, author = {Jan Philipp Dietrich and Lavinia Baumstark and Stephen Wirth and Anastasis Giannousakis and Renato Rodrigues and Benjamin Leon Bodirsky and Debbora Leip and Ulrich Kreidenweis and David Klein and Pascal Sauer}, year = {2023}, - note = {R package version 3.7.2}, + note = {R package version 3.7.3}, doi = {10.5281/zenodo.1115490}, url = {https://github.com/pik-piam/madrat}, } diff --git a/tests/testthat/test-calcOutput.R b/tests/testthat/test-calcOutput.R index e63327a0..74867925 100644 --- a/tests/testthat/test-calcOutput.R +++ b/tests/testthat/test-calcOutput.R @@ -127,7 +127,14 @@ test_that("Calculation for tau example data set works", { expect_equivalent(x$x, expectedResult) expect_message(x <- readSource("Tau", "historical"), "loading cache") expect_error(x <- readSource("Tau", "wtf"), "Unknown subtype") - expect_error(calcOutput("TauTotal", source = "historical", years = 1800), "Some years are missing") + expect_warning(calcOutput("TauTotal", source = "historical", years = 1800), "Some years are missing") + + x <- suppressWarnings(calcOutput("TauTotal", source = "historical", years = seq(1970, 2050, 1), + round = 2, supplementary = FALSE)) + expect_true(length(getYears(x, as.integer = TRUE)) == 38) + expect_true(1970 %in% getYears(x, as.integer = TRUE)) + expect_true(2007 %in% getYears(x, as.integer = TRUE)) + expect_false(2008 %in% getYears(x, as.integer = TRUE)) sink() })