Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/cran261 (#244) #245

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
> Copyright © 2016 RTE Réseau de transport d’électricité

# antaresRead 2.6.1 (devlopment)
# antaresRead 2.6.1

BUGFIXES :

Expand Down
18 changes: 5 additions & 13 deletions R/aggregateResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
#'
#' @param opts \code{list} of simulation parameters returned by the function \link{setSimulationPath}
#' @param nbcl \code{numeric} Number of parralel process
#' @param verbose \code{numeric} show log in console. Defaut to 1
#' \itemize{
#' \item{0}{ : No log}
#' \item{1}{ : Short log}
#' \item{2}{ : Long log}
#'}
#' @param verbose \code{numeric} show log in console. Defaut to 1
#' - 0 : No log
#' - 1 : Short log
#' - 2 : Long log
#' @param timestep \code{character} antares timestep
#' @param writeOutput \code{boolean} write result or not.
#' @param mcWeights \code{numeric} vector of weigth for mcYears.
Expand Down Expand Up @@ -689,12 +687,6 @@ parAggregateMCall <- function(opts,
}

#' @param opts \code{list} of simulation parameters returned by the function \link{setSimulationPath}
#' @param verbose \code{numeric} show log in console. Defaut to 1
#' \itemize{
#' \item{0}{ : No log}
#' \item{1}{ : Short log}
#' \item{2}{ : Long log}
#'}
#' @param timestep \code{character} antares timestep
#' @param writeOutput \code{boolean} write result or not.
#' @param mcWeights \code{numeric} vector of weigth for mcYears.
Expand Down Expand Up @@ -1533,7 +1525,7 @@ pmax.fast <- function(k,x) (x+k + abs(x-k))/2
#'
#' @import data.table
#'
#' @rdname aggregatate_mc_all_old
#' @noRd
#'
#' @examples
#' \dontrun{
Expand Down
32 changes: 16 additions & 16 deletions R/readClusterDesc.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ readClusterSTDesc <- function(opts = simOptions()) {
path <- file.path(opts$inputPath, dir)

columns <- .generate_columns_by_type(dir = dir)
api_study <- is_api_study(opts)

if(opts$typeLoad == 'api'){
if(api_study){

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

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


}else{

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

if(length(res) == 0){
warning("No cluster description available.", call. = FALSE)
res <- setNames(data.table(matrix(nrow = 0, ncol = 2 + length(columns))), c("area", "cluster", columns))
}else{
res <- as.data.table(res)
setnames(res, "name", "cluster")

res$cluster <- as.factor(tolower(res$cluster))
}

if(length(res) == 0){
mandatory_cols <- c("area","cluster")
warning("No cluster description available.", call. = FALSE)
res <- setNames(data.table(matrix(nrow = 0, ncol = length(mandatory_cols) + length(columns))), c(mandatory_cols, columns))
}else{
if(api_study){
mandatory_cols <- c("area", "name", "group")
additional_cols <- setdiff(colnames(res),mandatory_cols)
res <- res[, .SD, .SDcols = c(mandatory_cols, additional_cols)]
}
res <- as.data.table(res)
setnames(res, "name", "cluster")
res$cluster <- as.factor(tolower(res$cluster))
}

res
Expand Down
6 changes: 3 additions & 3 deletions man/aggregatate_mc_all.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 0 additions & 57 deletions man/aggregatate_mc_all_old.Rd

This file was deleted.

40 changes: 38 additions & 2 deletions tests/testthat/test-readClusterDesc.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,42 @@

## v860 ----
# v860 ----

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

#minimal columns
mandatory_cols <- c("area","cluster")

## Thermal ----
test_that("test read cluster", {

# function setSimulationPath() provide areas names with st-storage clusters
areas <- opts_study_test$areasWithClusters

# read clusters informations
input <- readClusterDesc()

# tests
testthat::expect_true("data.table" %in% class(input))
testthat::expect_true(all(areas %in% unique(readClusterDesc()$area)))
testthat::expect_true(all(mandatory_cols %in% colnames(input)))
testthat::expect_true(nrow(input) == length(input$cluster))

})

## Renewables ----
test_that("test read cluster renewables", {

# function setSimulationPath() provide areas names with st-storage clusters
areas_res <- opts_study_test$areasWithRESClusters

#Study not renewables (need activateRES() from antaresEditObject)
expect_error(readClusterResDesc(),
regexp = "readClusterDesc is available only on studies with 'renewable-generation-modelling'")

})

## st-storage ----
test_that("test read cluster st-storage v860", {

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

# tests
testthat::expect_true("data.table" %in% class(input_st))
testthat::expect_true(areas_st %in% unique(readClusterSTDesc()$area))
testthat::expect_true(all(areas_st %in% unique(readClusterSTDesc()$area)))
testthat::expect_true(all(mandatory_cols %in% colnames(input_st)))
testthat::expect_true(nrow(input_st) == length(input_st$cluster))

})
1 change: 0 additions & 1 deletion vignettes/antaresH5.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ BiocManager::install("rhdf5")

An other solution is to install manually these two packages from zip file. They are available here :
https://bioconductor.org/packages/release/bioc/html/zlibbioc.html
http://bioconductor.org/packages/release/bioc/html/rhdf5.html


## Avantages of h5 transformation
Expand Down
Loading