Skip to content

Commit

Permalink
Merge pull request #145 from rte-antares-rpackage/ant1489/bug
Browse files Browse the repository at this point in the history
CreateCluster default matrix case in API mode
  • Loading branch information
berthetclement authored Mar 28, 2024
2 parents d6c347f + 3a6bbeb commit 38391bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ NEW FEATURES :
* `.createCluster()` uses data.table::fwrite() instead of utils::write.table() for optimization
* `createCluster()` parameter `list_pollutants` default value to NULL.
* `createBindingConstraint()` parameter `coefficients` must be alphabetically ordered.
* `.createCluster()` default matrix in API mode.

BUGFIXES :

Expand Down
28 changes: 15 additions & 13 deletions R/createCluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -333,21 +333,23 @@ createClusterRES <- function(area,
cli_command_registered("create_cluster")
)

if (!is.null(time_series)) {
currPath <- ifelse(identical(cluster_type, "renewables"), "input/renewables/series/%s/%s/series", "input/thermal/series/%s/%s/series")
cmd <- api_command_generate(
action = "replace_matrix",
target = sprintf(currPath, area, lower_cluster_name),
matrix = time_series
)
api_command_register(cmd, opts = opts)
`if`(
should_command_be_executed(opts),
api_command_execute(cmd, opts = opts, text_alert = "Writing cluster's series: {msg_api}"),
cli_command_registered("replace_matrix")
)
if (is.null(time_series)) {
time_series <- matrix(0,8760) #Default
}

currPath <- ifelse(identical(cluster_type, "renewables"), "input/renewables/series/%s/%s/series", "input/thermal/series/%s/%s/series")
cmd <- api_command_generate(
action = "replace_matrix",
target = sprintf(currPath, area, lower_cluster_name),
matrix = time_series
)
api_command_register(cmd, opts = opts)
`if`(
should_command_be_executed(opts),
api_command_execute(cmd, opts = opts, text_alert = "Writing cluster's series: {msg_api}"),
cli_command_registered("replace_matrix")
)

return(invisible(opts))
}

Expand Down

0 comments on commit 38391bb

Please sign in to comment.