Skip to content

Commit

Permalink
Fix bug readini (#235)
Browse files Browse the repository at this point in the history
* change .format_list, recursive function to get the list of list of list etc...

* DESCRIPTION and NEWS.md

* resolve bug, replace recursivity by for loop
  • Loading branch information
Nekmek7 authored Feb 16, 2024
1 parent 9901e21 commit 505c75a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: antaresRead
Type: Package
Title: Import, Manipulate and Explore the Results of an 'Antares' Simulation
Version: 2.6.2
Version: 2.6.1
Authors@R: c(
person("Tatiana", "Vargas", email = "[email protected]", role = c("aut", "cre")),
person("Jalal-Edine", "ZAWAM", role = "aut"),
Expand All @@ -14,6 +14,7 @@ Authors@R: c(
person("Assil", "Mansouri", role = "ctb"),
person("Clement", "Berthet", role = "ctb"),
person("Kamel", "Kemiha", role = "ctb"),
person("Abdallah", "Mahoudi", role = "ctb"),
person("RTE", role = "cph")
)
Description: Import, manipulate and explore results generated by 'Antares', a
Expand Down
12 changes: 4 additions & 8 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
> Copyright © 2016 RTE Réseau de transport d’électricité
# antaresRead 2.6.2 (devlopment)

BUGFIXES :

* `readAntares()` :
- returns the right column names for details-timeStep.txt and details-res-timeStep.txt


# antaresRead 2.6.1 (devlopment)

BUGFIXES :
Expand All @@ -16,6 +8,10 @@ BUGFIXES :
- returns an API exception if the requested study ID is incorrect
- `simulation` the simulation parameter works with negative values within the limit of the number of simulations
* correction in `readClusterDesc()` calls to add "opts"
* `readAntares()` :
- returns the right column names for details-timeStep.txt and details-res-timeStep.txt
* Correction in `.formatlist()`, read N-level list instead of 2.



# antaresRead 2.6.0
Expand Down
24 changes: 13 additions & 11 deletions R/readIniFile.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ readIniFile <- function(file, stringsAsFactors = FALSE) {
pairs <- X[seq(starts[i], ends[i])]
pairs <- pairs[pairs != ""]
pairs <- strsplit(pairs, "=")

key <- lapply(pairs, `[`, 1)
key <- unlist(key)
key <- trimws(key)

value <- lapply(pairs, `[`, 2)
value <- as.list(trimws(unlist(value)))
value <- lapply(value, function(x) {
Expand All @@ -83,7 +83,7 @@ readIniFile <- function(file, stringsAsFactors = FALSE) {
utils::type.convert(x, as.is = TRUE)
}
})

L[[i]] <- value
names(L[[i]]) <- key
}
Expand Down Expand Up @@ -131,15 +131,17 @@ readIniAPI <- function(study_id, path, host, token = NULL) {
if(is.name(x[index_list]))
return(x)
else{
elements <- unlist(x[index_list], use.names = FALSE)
if(class(elements)%in%"character"){
elements <- paste("'", elements, "'", sep="", collapse=",")
elements <- paste0("[", elements, "]")
}else{
elements <- paste0(elements, collapse= ",")
elements <- paste0("[", elements, "]")
for (sub_list in index_list){
elements <- unlist(x[sub_list], use.names = FALSE)
if(class(elements)%in%"character"){
elements <- paste("'", elements, "'", sep="", collapse=",")
elements <- paste0("[", elements, "]")
}else{
elements <- paste0(elements, collapse= ",")
elements <- paste0("[", elements, "]")
}
x[sub_list] <- elements
}
x[index_list] <- elements
x
}
})
Expand Down

0 comments on commit 505c75a

Please sign in to comment.