Skip to content

Commit

Permalink
sort extractVariableGroups; put decimal test first
Browse files Browse the repository at this point in the history
  • Loading branch information
orichters committed Sep 4, 2024
1 parent 4459af1 commit a5bb830
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion R/checkSummations.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-getMapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit a5bb830

Please sign in to comment.