Skip to content

Commit a8ee40b

Browse files
Ant2929/generaldata (#212)
* resync doc * activateRES() minor updates * updateAdequacySettings() display warning 'lifecycle' for parameters removed from Antares 9.2 * update pkgdown site with bootstrap 5 + fix some warnings about vignette
1 parent 5907e2b commit a8ee40b

14 files changed

+88
-37
lines changed

NEWS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55

66
NEW FEATURES :
77

8+
* `createClusterST()`/`editClusterST()` : Parameter `group` is now dynamic and have no restriction
89
* `createClusterST()`/`editClusterST()` :
910
- **New properties** (*efficiencywithdrawal*, *penalize-variation-injection*, *penalize-variation-withdrawal*, see list of properties according to study version of Antares with `storage_values_default()`)
1011
- **New optional time series** (cost-injection, cost-withdrawal, cost-level, cost-variation-injection, cost-variation-withdrawal)
1112

1213
### Breaking changes :
13-
- `createClusterST()`/`editClusterST()` : parameter `group` is now dynamic and have no restriction
14-
- `createClusterST()` : for a study < 9.2, execution will be STOP if `group` is not included in list (see doc)
14+
- `createClusterST()` : For a study < *v9.2*, execution will be STOP if `group` is not included in list (see doc)
15+
- `updateAdequacySettings()` : Two parameters (*enable-first-step*, *set-to-null-ntc-between-physical-out-for-first-step*) are `deprecated` and removed. Parameters are forced to `NULL` with study >= v9.2.
1516

1617

1718
### DOC :

R/RES.R

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99
#' appropriate structure for RES clusters.
1010
#' @param quietly Display or not a message to the user if success.
1111
#'
12-
#' @param opts
13-
#' List of simulation parameters returned by the function
14-
#' \code{antaresRead::setSimulationPath}
15-
#'
16-
#' @return An updated list containing various information about the simulation.
12+
#' @template opts
1713
#' @export
1814
#'
1915
#' @examples

R/createClusterST.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
#' "my_cluster",
115115
#' storage_parameters = my_parameters)
116116
#'
117-
#'
118117
#' # time series
119118
#' ratio_value <- matrix(0.7, 8760)
120119
#'

R/updateAdequacySettings.R

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,45 @@ updateAdequacySettings <- function(include_adq_patch = NULL,
7777
new_params <- new_params[!names(new_params) %in% properties_850]
7878
}
7979

80-
if (opts[["antaresVersion"]] >= 860) {
80+
if (opts[["antaresVersion"]] >= 860 &&
81+
opts[["antaresVersion"]] <920) {
8182
if ("enable_first_step" %in% names(new_params)) {
8283
message("Property enable_first_step is disabled for the moment. Set to FALSE.\n")
8384
new_params[["enable_first_step"]] <- FALSE
8485
}
8586
}
8687

87-
new_params <- lapply(X = new_params, FUN = .format_ini_rhs)
88-
names(new_params) <- sapply(names(new_params), dicoAdequacySettings, USE.NAMES = FALSE)
88+
# display a warning for these parameters
89+
if (opts[["antaresVersion"]] >= 920) {
90+
short_name <- set_to_null_ntc_between_physical_out_for_first_step
91+
if (!is.null(enable_first_step)){
92+
lifecycle::deprecate_warn(
93+
when = "2.9.2",
94+
what = "antaresEditObject::updateAdequacySettings(enable_first_step)",
95+
details = "This parameter are no longer supported for an Antares version >= '9.2', the values will be ignored."
96+
)
97+
new_params[["enable_first_step"]] <- NULL
98+
}
99+
if(!is.null(short_name)){
100+
lifecycle::deprecate_warn(
101+
when = "2.9.2",
102+
what = "antaresEditObject::updateAdequacySettings(set_to_null_ntc_between_physical_out_for_first_step)",
103+
details = "This parameter are no longer supported for an Antares version >= '9.2', the values will be ignored."
104+
)
105+
new_params[["set_to_null_ntc_between_physical_out_for_first_step"]] <- NULL
106+
}
107+
}
108+
109+
new_params <- lapply(X = new_params,
110+
FUN = .format_ini_rhs)
111+
112+
names(new_params) <- sapply(names(new_params),
113+
dicoAdequacySettings,
114+
USE.NAMES = FALSE)
89115

90-
res <- update_generaldata_by_section(opts = opts, section = "adequacy patch", new_params = new_params)
116+
res <- update_generaldata_by_section(opts = opts,
117+
section = "adequacy patch",
118+
new_params = new_params)
91119

92120
invisible(res)
93121
}

R/utils.R

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,15 @@ generate_cluster_name <- function(area, cluster_name, add_prefix) {
183183
#' @importFrom antaresRead readIniFile
184184
update_generaldata_by_section <- function(opts, section, new_params) {
185185

186-
if (is_api_study(opts = opts)) {
186+
if (is_api_study(opts = opts))
187+
writeIni(listData = new_params,
188+
pathIni = sprintf("settings/generaldata/%s", section),
189+
opts = opts)
187190

188-
writeIni(listData = new_params, pathIni = sprintf("settings/generaldata/%s", section), opts = opts)
189-
190-
} else {
191-
192-
generaldatapath <- file.path(opts[["studyPath"]], "settings", "generaldata.ini")
191+
else {
192+
generaldatapath <- file.path(opts[["studyPath"]],
193+
"settings",
194+
"generaldata.ini")
193195
generaldata <- readIniFile(file = generaldatapath)
194196

195197
if (section %in% names(generaldata)) {
@@ -199,9 +201,10 @@ update_generaldata_by_section <- function(opts, section, new_params) {
199201
l_section <- new_params
200202
}
201203
generaldata[[section]] <- l_section
202-
203-
writeIni(listData = generaldata, pathIni = generaldatapath, overwrite = TRUE, opts = opts)
204+
writeIni(listData = generaldata,
205+
pathIni = generaldatapath,
206+
overwrite = TRUE,
207+
opts = opts)
204208
}
205-
206209
return(update_opts(opts = opts))
207210
}

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
<img src="man/figures/antares_simulator.png" align="right" width=250 />
1+
# antaresEditObject <img src="man/figures/antares_simulator.png" align="right" alt="" width=250 />
22
<br/>
33

4-
# antaresEditObject
5-
6-
7-
> Edit an Antares study before running a simulation.
8-
94
<!-- badges: start -->
105
[![CRAN status](https://www.r-pkg.org/badges/version/antaresEditObject)](https://CRAN.R-project.org/package=antaresEditObject)
116
[![cranlogs](https://cranlogs.r-pkg.org/badges/antaresEditObject)](https://cran.r-project.org/package=antaresEditObject)
@@ -15,6 +10,8 @@
1510
[![Codecov test coverage](https://codecov.io/gh/rte-antares-rpackage/antaresEditObject/graph/badge.svg)](https://app.codecov.io/gh/rte-antares-rpackage/antaresEditObject)
1611
<!-- badges: end -->
1712

13+
> Edit an Antares study before running a simulation.
14+
1815

1916
## Installation
2017

_pkgdown.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ development:
22
mode: auto
33
destination: docs/release920
44
template:
5-
params:
6-
bootswatch: readable
5+
bootstrap: 5
6+
light-switch: true
77

man/activateRES.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/createClusterST.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-updateAdequacyPatch.R

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,31 @@ test_that("Update an adequacy parameter for an Antares version 860", {
3333

3434
unlink(x = opts$studyPath, recursive = TRUE)
3535
})
36+
37+
# >= v920 ----
38+
suppressWarnings(
39+
createStudy(path = tempdir(),
40+
study_name = "st-storage9.2",
41+
antares_version = "9.2"))
42+
43+
test_that("Properties removed", {
44+
lifecycle::expect_deprecated(
45+
updateAdequacySettings(
46+
set_to_null_ntc_between_physical_out_for_first_step = FALSE),
47+
regexp = "The `set_to_null_ntc_between_physical_out_for_first_step` argument"
48+
)
49+
50+
lifecycle::expect_deprecated(
51+
updateAdequacySettings(enable_first_step = FALSE),
52+
regexp = "The `enable_first_step` argument"
53+
)
54+
55+
# read general parameters
56+
parameters <- readIni("settings/generaldata")
57+
params <- parameters[["adequacy patch"]]
58+
59+
# tests if NULL are well forced
60+
expect_equal(length(params), 0)
61+
})
62+
63+
deleteStudy()

0 commit comments

Comments
 (0)