Skip to content

Commit

Permalink
Merge branch 'develop' into 2017MakeUse
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-young committed Feb 28, 2024
2 parents 8e8de01 + f3cc60a commit c015264
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions R/ConfigurationFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ getConfiguration <- function(configname, configtype, configpaths = NULL, pkg="us
}
}
config <- configr::read.config(configpath)
if (typeof(config) == "logical" && config == FALSE) {
logging::logwarn(paste0("Configuration not found for ", configname))
return(NULL)
}
return(config)
}

Expand Down
2 changes: 1 addition & 1 deletion R/InitializeModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ initializeModel <- function(modelname, configpaths = NULL) {
model <- list()
# Get model specs
model$specs <- getConfiguration(modelname, "model", configpaths)
if (rlang::is_na(model$specs)) {
if (is.null(model$specs)) {
stop(paste("No configuration exists for a model named", modelname))
} else {
# Get model crosswalk
Expand Down
3 changes: 3 additions & 0 deletions R/LCIAfmtFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ getImpactMethod <- function(ind_spec) {
# Subset the method by indicator
if(!is.null(indicators)){
imp_method <- imp_method[imp_method$Indicator %in% indicators, ]
if(nrow(imp_method)==0) {
logging::logwarn("Error selecting indicators from method")
}
}

return(imp_method)
Expand Down
12 changes: 11 additions & 1 deletion R/LoadSatellites.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,20 @@ generateTbSfromSatSpec <- function(sat_spec, model) {
}
}
totals_by_sector <- do.call(eval(totalsgenfunction), list(params))
} else {
} else if (sat_spec$FileLocation == "DataCommons") {
f <- loadDataCommonsfile(sat_spec$StaticFile)
totals_by_sector <- utils::read.table(f, sep = ",", header = TRUE, stringsAsFactors = FALSE,
fileEncoding = 'UTF-8-BOM')
} else {
totals_by_sector <- utils::read.table(sat_spec$StaticFile, sep = ",",
header = TRUE, stringsAsFactors = FALSE,
fileEncoding = 'UTF-8-BOM')
}
# Ensure context is not NA
for (i in c('Context')) {
if (all(is.na(totals_by_sector[, i]))) {
totals_by_sector[ , i] <- ""
}
}
return(totals_by_sector)
}
Expand Down

0 comments on commit c015264

Please sign in to comment.