Skip to content

Commit

Permalink
Merge pull request #66 from rte-antares-rpackage/editCluster_devs
Browse files Browse the repository at this point in the history
Fix for case sensitivity in editCluster() API
  • Loading branch information
AssilMa authored Jan 19, 2023
2 parents 9cb714e + 2870c11 commit e29534d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: antaresEditObject
Type: Package
Title: Edit an 'Antares' Simulation
Version: 0.4.0
Version: 0.4.1
Authors@R: c(
person("Veronique", "Bachelier", email = "veronique.bachelier@rte-france.com", role = c("aut", "cre")),
person("Frederic", "Breant", role = "aut"),
Expand All @@ -12,6 +12,7 @@ Authors@R: c(
person("Jalal-Edine", "Zawam", role = "ctb"),
person("Etienne", "Sanchez", role = "ctb"),
person("Janus", "De Bondt", role = "ctb"),
person("Assil", "Mansouri", role = "ctb"),
person("RTE", role = "cph"))
Description: Edit an 'Antares' simulation before running it : create new areas, links, thermal
clusters or binding constraints or edit existing ones. Update 'Antares' general & optimization settings.
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# antaresEditObject 0.4.1

BUGFIXES :

* Fix case sensitivity for `editCluster()` in API mode



# antaresEditObject 0.4.0

### New functions
Expand Down
19 changes: 19 additions & 0 deletions R/editCluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,25 @@ editClusterRES <- function(area,
params_cluster <- hyphenize_names(list(...))
if (add_prefix)
cluster_name <- paste(area, cluster_name, sep = "_")

# Handle case sensitivity in name of clusters API
clusters <- names(readIni(file.path("input", cluster_type, "clusters", area, "list")))

if (!cluster_name %in% clusters){
if (tolower(cluster_name) %in% tolower(clusters)){
cluster_idx <- which(tolower(clusters) %in% tolower(cluster_name))
cluster_name <- clusters[cluster_idx]
if (length(cluster_name) > 1)
warning("detected multiple clusters : ", do.call(paste, as.list(cluster_name)), ", only the first one will be edited.")
cluster_name <- cluster_name[1]
} else {
stop(
"'", cluster_name, "' doesn't exist, it can't be edited. You can create cluster with createCluster().",
call. = FALSE
)
}
}

params_cluster$name <- cluster_name

if (!NROW(time_series) %in% c(0, 8736, 8760)) {
Expand Down
2 changes: 1 addition & 1 deletion vignettes/api-variant-management.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ getVariantCommands(last = 2)

Edit a cluster with:

```{r edit_cluster}
```{r edit_cluster, eval = FALSE}
createCluster(
area = "area02",
cluster_name = "clus02"
Expand Down

0 comments on commit e29534d

Please sign in to comment.