diff --git a/DESCRIPTION b/DESCRIPTION index a5d8725fc..ce0ae593f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -14,7 +14,7 @@ Imports: dplyr (>= 1.1.1), gms, magclass, - mip (>= 0.144.3), + mip (>= 0.149.3), readxl, quitte (>= 0.3137.1), piamutils (>= 0.0.12), diff --git a/R/checkSummations.R b/R/checkSummations.R index afdeb0750..e55459f7e 100644 --- a/R/checkSummations.R +++ b/R/checkSummations.R @@ -51,7 +51,7 @@ checkSummations <- function(mifFile, outputDirectory = ".", template = NULL, sum summationsFile <- chooseFromList(summationsOptions, multiple = FALSE, type = "summation file") } if (isTRUE(summationsFile == "extractVariableGroups")) { - checkVariables <- extractVariableGroups(levels(data$variable), keepOrigNames = TRUE) + checkVariables <- extractVariableGroups(levels(data$variable), keepOrigNames = TRUE, sorted = TRUE) names(checkVariables) <- make.unique(names(checkVariables), sep = " ") } else { summationGroups <- getSummations(summationsFile) diff --git a/tests/testthat/test-getMapping.R b/tests/testthat/test-getMapping.R index 884294fd8..2ccf4ac87 100644 --- a/tests/testthat/test-getMapping.R +++ b/tests/testthat/test-getMapping.R @@ -15,6 +15,19 @@ for (mapping in names(mappingNames())) { } expect_true(length(conflictsigns) == 0, label = paste0(mapping, " has no merge conflicts")) + # check whether piam_factor column has , as decimal separator + factorWithComma <- mappingData %>% + filter(grepl(",", .data$piam_factor)) %>% + pull("variable") + if (length(factorWithComma) > 0) { + warning("These variables in mapping ", mapping, " have a piam_factor using a ',' as decimal. Please use '.':\n", + paste(factorWithComma, collapse = "\n"), + "\nYou can run: devtools::load_all(); write.csv2(getMapping('", mapping, + "') %>% mutate(piam_factor = gsub(',', '.', .data$piam_factor)), mappingNames('", mapping, + "'), na = '', row.names = FALSE, quote = FALSE)") + } + expect_true(length(factorWithComma) == 0) + # look for Moving Avg prices in REMIND variables movingavg <- mappingData %>% filter(grepl("^Price\\|.*\\|Moving Avg", .data$piam_variable), @@ -90,19 +103,6 @@ for (mapping in names(mappingNames())) { } expect_true(length(factorWithoutVar) == 0) - # check whether piam_factor column has , as decimal separator - factorWithComma <- mappingData %>% - filter(grepl(",", .data$piam_factor)) %>% - pull("variable") - if (length(factorWithComma) > 0) { - warning("These variables in mapping ", mapping, " have a piam_factor using a ',' as decimal. Please use '.':\n", - paste(factorWithComma, collapse = "\n"), - "\nYou can run: devtools::load_all(); write.csv2(getMapping('", mapping, - "') %>% mutate(piam_factor = gsub(',', '.', .data$piam_factor)), mappingNames('", mapping, - "'), na = '', row.names = FALSE, quote = FALSE)") - } - expect_true(length(factorWithComma) == 0) - # checks only if source is supplied if ("source" %in% colnames(mappingData)) { # check for empty piam_variable with source