Skip to content

Commit 23d8954

Browse files
Release/cran261 (#244)
* update github workflow * Read cluster desc bugfix when cluster exist (#242) * fix bug readClusterDesc when no cluster + cover ST and RES case * add test (init test for thermal + res) * cleaning * fix cran NOTE causing by bad url in doc + bad doc
1 parent e54b25f commit 23d8954

File tree

7 files changed

+63
-93
lines changed

7 files changed

+63
-93
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
> Copyright © 2016 RTE Réseau de transport d’électricité
22
3-
# antaresRead 2.6.1 (devlopment)
3+
# antaresRead 2.6.1
44

55
BUGFIXES :
66

R/aggregateResult.R

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
#'
55
#' @param opts \code{list} of simulation parameters returned by the function \link{setSimulationPath}
66
#' @param nbcl \code{numeric} Number of parralel process
7-
#' @param verbose \code{numeric} show log in console. Defaut to 1
8-
#' \itemize{
9-
#' \item{0}{ : No log}
10-
#' \item{1}{ : Short log}
11-
#' \item{2}{ : Long log}
12-
#'}
7+
#' @param verbose \code{numeric} show log in console. Defaut to 1
8+
#' - 0 : No log
9+
#' - 1 : Short log
10+
#' - 2 : Long log
1311
#' @param timestep \code{character} antares timestep
1412
#' @param writeOutput \code{boolean} write result or not.
1513
#' @param mcWeights \code{numeric} vector of weigth for mcYears.
@@ -689,12 +687,6 @@ parAggregateMCall <- function(opts,
689687
}
690688

691689
#' @param opts \code{list} of simulation parameters returned by the function \link{setSimulationPath}
692-
#' @param verbose \code{numeric} show log in console. Defaut to 1
693-
#' \itemize{
694-
#' \item{0}{ : No log}
695-
#' \item{1}{ : Short log}
696-
#' \item{2}{ : Long log}
697-
#'}
698690
#' @param timestep \code{character} antares timestep
699691
#' @param writeOutput \code{boolean} write result or not.
700692
#' @param mcWeights \code{numeric} vector of weigth for mcYears.
@@ -1533,7 +1525,7 @@ pmax.fast <- function(k,x) (x+k + abs(x-k))/2
15331525
#'
15341526
#' @import data.table
15351527
#'
1536-
#' @rdname aggregatate_mc_all_old
1528+
#' @noRd
15371529
#'
15381530
#' @examples
15391531
#' \dontrun{

R/readClusterDesc.R

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ readClusterSTDesc <- function(opts = simOptions()) {
107107
path <- file.path(opts$inputPath, dir)
108108

109109
columns <- .generate_columns_by_type(dir = dir)
110+
api_study <- is_api_study(opts)
110111

111-
if(opts$typeLoad == 'api'){
112+
if(api_study){
112113

113114
jsoncld <- read_secure_json(paste0(path, "&depth=4"), token = opts$token, timeout = opts$timeout, config = opts$httr_config)
114115
res <- rbindlist(mapply(function(X1, Y1){
@@ -125,13 +126,6 @@ readClusterSTDesc <- function(opts = simOptions()) {
125126
clusters[, .SD, .SDcols = order(names(clusters))]
126127
},jsoncld, names(jsoncld), SIMPLIFY = FALSE), fill = TRUE)
127128

128-
if(length(res) == 0){
129-
warning("No cluster description available.", call. = FALSE)
130-
res <- setNames(data.table(matrix(nrow = 0, ncol = 2 + length(columns))), c("area", "cluster", columns))
131-
}else{
132-
res <- res[, .SD, .SDcols = c("area", "name", "group", names(res)[!names(res) %in%c("area", "name", "group")])]
133-
}
134-
135129

136130
}else{
137131

@@ -149,15 +143,21 @@ readClusterSTDesc <- function(opts = simOptions()) {
149143
clusters[, c(ncol(clusters), 1:(ncol(clusters) - 1))]
150144
})
151145

152-
if(length(res) == 0){
153-
warning("No cluster description available.", call. = FALSE)
154-
res <- setNames(data.table(matrix(nrow = 0, ncol = 2 + length(columns))), c("area", "cluster", columns))
155-
}else{
156-
res <- as.data.table(res)
157-
setnames(res, "name", "cluster")
158-
159-
res$cluster <- as.factor(tolower(res$cluster))
146+
}
147+
148+
if(length(res) == 0){
149+
mandatory_cols <- c("area","cluster")
150+
warning("No cluster description available.", call. = FALSE)
151+
res <- setNames(data.table(matrix(nrow = 0, ncol = length(mandatory_cols) + length(columns))), c(mandatory_cols, columns))
152+
}else{
153+
if(api_study){
154+
mandatory_cols <- c("area", "name", "group")
155+
additional_cols <- setdiff(colnames(res),mandatory_cols)
156+
res <- res[, .SD, .SDcols = c(mandatory_cols, additional_cols)]
160157
}
158+
res <- as.data.table(res)
159+
setnames(res, "name", "cluster")
160+
res$cluster <- as.factor(tolower(res$cluster))
161161
}
162162

163163
res

man/aggregatate_mc_all.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/aggregatate_mc_all_old.Rd

Lines changed: 0 additions & 57 deletions
This file was deleted.

tests/testthat/test-readClusterDesc.R

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,42 @@
11

2-
## v860 ----
2+
# v860 ----
33

44
path_study_test <- grep(pattern = "86", x = studyPathSV8, value = TRUE)
55
opts_study_test <- setSimulationPath(path_study_test, simulation = "input")
66

7+
#minimal columns
8+
mandatory_cols <- c("area","cluster")
9+
10+
## Thermal ----
11+
test_that("test read cluster", {
12+
13+
# function setSimulationPath() provide areas names with st-storage clusters
14+
areas <- opts_study_test$areasWithClusters
15+
16+
# read clusters informations
17+
input <- readClusterDesc()
18+
19+
# tests
20+
testthat::expect_true("data.table" %in% class(input))
21+
testthat::expect_true(all(areas %in% unique(readClusterDesc()$area)))
22+
testthat::expect_true(all(mandatory_cols %in% colnames(input)))
23+
testthat::expect_true(nrow(input) == length(input$cluster))
24+
25+
})
26+
27+
## Renewables ----
28+
test_that("test read cluster renewables", {
29+
30+
# function setSimulationPath() provide areas names with st-storage clusters
31+
areas_res <- opts_study_test$areasWithRESClusters
32+
33+
#Study not renewables (need activateRES() from antaresEditObject)
34+
expect_error(readClusterResDesc(),
35+
regexp = "readClusterDesc is available only on studies with 'renewable-generation-modelling'")
36+
37+
})
38+
39+
## st-storage ----
740
test_that("test read cluster st-storage v860", {
841

942
# function setSimulationPath() provide areas names with st-storage clusters
@@ -14,5 +47,8 @@ test_that("test read cluster st-storage v860", {
1447

1548
# tests
1649
testthat::expect_true("data.table" %in% class(input_st))
17-
testthat::expect_true(areas_st %in% unique(readClusterSTDesc()$area))
50+
testthat::expect_true(all(areas_st %in% unique(readClusterSTDesc()$area)))
51+
testthat::expect_true(all(mandatory_cols %in% colnames(input_st)))
52+
testthat::expect_true(nrow(input_st) == length(input_st$cluster))
53+
1854
})

vignettes/antaresH5.Rmd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ BiocManager::install("rhdf5")
3535
3636
An other solution is to install manually these two packages from zip file. They are available here :
3737
https://bioconductor.org/packages/release/bioc/html/zlibbioc.html
38-
http://bioconductor.org/packages/release/bioc/html/rhdf5.html
3938
4039
4140
## Avantages of h5 transformation

0 commit comments

Comments
 (0)