diff --git a/DESCRIPTION b/DESCRIPTION index df757804..54bf0487 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: antaresViz Type: Package Title: Antares Visualizations -Version: 0.18.0 +Version: 0.18.2 Authors@R: c( person("Tatiana", "Vargas", email = "tatiana.vargas@rte-france.com", role = c("aut", "cre")), person("Jalal-Edine", "Zawam", role = "aut"), @@ -45,14 +45,13 @@ Imports: leaflet.minicharts (>= 0.5.3), assertthat, rAmCharts, - utils + utils, + lifecycle RoxygenNote: 7.2.2 Suggests: testthat, covr, - rhdf5 (>= 2.20.2), ggplot2, - hexbin, knitr, visNetwork, rmarkdown diff --git a/NAMESPACE b/NAMESPACE index ac472e79..48d300b7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -56,6 +56,9 @@ importFrom(grDevices,rainbow) importFrom(grDevices,rgb) importFrom(graphics,par) importFrom(graphics,plot.default) +importFrom(lifecycle,deprecate_warn) +importFrom(lifecycle,deprecated) +importFrom(lifecycle,is_present) importFrom(methods,is) importFrom(plotly,add_bars) importFrom(plotly,add_heatmap) diff --git a/NEWS.md b/NEWS.md index ee6a7218..f0ae2f83 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,11 @@ Copyright 2016 RTE Reseau de transport d'electricite +# antaresViz 0.18.2 +* fix cran issue on test not skip well + +# antaresViz 0.18.1 +* delete package dependecies `rhdf5` + # antaresViz 0.18.0 * fix deprecated dependencies (issue #200) * packages `rgeos`, `raster` removed and replaced by `sf` diff --git a/R/graph_utils.R b/R/graph_utils.R index f730f234..d41cd4ce 100644 --- a/R/graph_utils.R +++ b/R/graph_utils.R @@ -289,71 +289,6 @@ } - - -#' List of h5 params -#' -#' @param X_I, list -#' @param xyCompare, character -#' -#' @noRd -.h5ParamList <- function(X_I, xyCompare, h5requestFilter = NULL){ - listParam <- lapply(1:length(X_I), function(i){ - x <- X_I[[i]] - if (.isSimOpts(x)){ - tmp <- .h5Inf(x) - h5_filter <- h5requestFilter[[i]] - h5_tables <- c("areas", "districts", "clusters", "links") - if (!is.null(h5_filter)){ - if (!(is.null(h5_filter$areas) & is.null(h5_filter$districts) & - is.null(h5_filter$links) & is.null(h5_filter$clusters))){ - h5_tables <- c("areas", "districts", "clusters", "links") - h5_tables <- h5_tables[which(c(!is.null(h5_filter$areas), !is.null(h5_filter$districts), - !is.null(h5_filter$clusters), !is.null(h5_filter$links)))] - } - } - tmp$tabl <- intersect(tmp$tabl, h5_tables) - rhdf5::H5close() - tmp - }else{ - mcY <- unique(unlist(lapply(x, function(y){unique(y$mcYears)}))) - timeStepS <- attributes(x)$timeStep - tabl <- names(x) - list( - timeStepS = timeStepS, - mcYearS = mcY, - tabl = tabl - ) - } - }) - res <- lapply(.transposeL(listParam), function(x){ - .compareOperation(x, xyCompare) - }) - - res$h5requestFilter <- h5requestFilter - res -} - -#' Load information from h5 file -#' -#' @param x, opts -#' -#' @noRd -.h5Inf <- function(x){ - fid <- rhdf5::H5Fopen(x$h5path) - timeStepS <- .getTimeStep(fid) - timeStepS <- as.character(timeStepS) - mcYearS <- x$mcYears - tabl <- .getTableInH5(fid, timeStepS[1]) - rhdf5::H5Fclose(fid) - xPart = list( - timeStepS = timeStepS, - mcYearS = mcYearS, - tabl = tabl - ) -} - - .transposeL <- function(data){ do.call(c, apply(do.call(rbind, data), 2, list)) } diff --git a/R/h5_utils.R b/R/h5_utils.R index 3405373d..c9b8053f 100644 --- a/R/h5_utils.R +++ b/R/h5_utils.R @@ -1,109 +1,109 @@ -.convertH5Filtering <- function(h5requestFiltering, x) -{ - if (length(h5requestFiltering) > 0) - { - if (!is.list(h5requestFiltering[[1]])){ - if (!any(c("simOptions", "antaresDataTable") %in% class(x))) - { - h5requestFiltering <- rep(list(h5requestFiltering), length(x)) - }else{ - h5requestFiltering <- list(h5requestFiltering) - } - }else{ - if (inherits(x, "list")){ - if (length(h5requestFiltering) != length(x)){ - h5requestFiltering <- h5requestFiltering[1:length(x) %% length(h5requestFiltering) + 1] - } - } - } - }else{ - if (!any(c("simOptions", "antaresDataTable") %in% class(x))) - { - h5requestFiltering <- replicate(length(x), list()) - }else{ - h5requestFiltering <- replicate(1, list()) - } - } - h5requestFiltering -} +# .convertH5Filtering <- function(h5requestFiltering, x) +# { +# if (length(h5requestFiltering) > 0) +# { +# if (!is.list(h5requestFiltering[[1]])){ +# if (!any(c("simOptions", "antaresDataTable") %in% class(x))) +# { +# h5requestFiltering <- rep(list(h5requestFiltering), length(x)) +# }else{ +# h5requestFiltering <- list(h5requestFiltering) +# } +# }else{ +# if (inherits(x, "list")){ +# if (length(h5requestFiltering) != length(x)){ +# h5requestFiltering <- h5requestFiltering[1:length(x) %% length(h5requestFiltering) + 1] +# } +# } +# } +# }else{ +# if (!any(c("simOptions", "antaresDataTable") %in% class(x))) +# { +# h5requestFiltering <- replicate(length(x), list()) +# }else{ +# h5requestFiltering <- replicate(1, list()) +# } +# } +# h5requestFiltering +# } -.getTableInH5 <- function(fid, timeStep){ - dataExist <- NULL - if (rhdf5::H5Lexists(fid, paste0(timeStep, "/areas"))) - { - dataExist <- c(dataExist, "areas") - } - if (rhdf5::H5Lexists(fid, paste0(timeStep, "/links"))) - { - dataExist <- c(dataExist, "links") - } - if (rhdf5::H5Lexists(fid, paste0(timeStep, "/clusters"))) - { - dataExist <- c(dataExist, "clusters") - } - if (rhdf5::H5Lexists(fid, paste0(timeStep, "/districts"))) - { - dataExist <- c(dataExist, "districts") - } - dataExist -} +# .getTableInH5 <- function(fid, timeStep){ +# dataExist <- NULL +# if (rhdf5::H5Lexists(fid, paste0(timeStep, "/areas"))) +# { +# dataExist <- c(dataExist, "areas") +# } +# if (rhdf5::H5Lexists(fid, paste0(timeStep, "/links"))) +# { +# dataExist <- c(dataExist, "links") +# } +# if (rhdf5::H5Lexists(fid, paste0(timeStep, "/clusters"))) +# { +# dataExist <- c(dataExist, "clusters") +# } +# if (rhdf5::H5Lexists(fid, paste0(timeStep, "/districts"))) +# { +# dataExist <- c(dataExist, "districts") +# } +# dataExist +# } -.getVariablesH5 <- function(fid, timeStep, tables){ - sapply(tables, function(X){ - struct <- .getstructure(fid, paste0(timeStep, "/", X, "/mcInd/", "/structure"))$variable - if ("timeId" %in% struct){ - struct <- struct[struct != "timeId"] - } - struct - }, simplify = FALSE) -} +# .getVariablesH5 <- function(fid, timeStep, tables){ +# sapply(tables, function(X){ +# struct <- .getstructure(fid, paste0(timeStep, "/", X, "/mcInd/", "/structure"))$variable +# if ("timeId" %in% struct){ +# struct <- struct[struct != "timeId"] +# } +# struct +# }, simplify = FALSE) +# } -.getClustersNames <- function(fid, timeStep){ - unique(unlist(lapply(strsplit(.getstructure(fid, paste0(timeStep, "/clusters/mcInd/structure"))$cluster, "/"), function(X)X[1]))) -} +# .getClustersNames <- function(fid, timeStep){ +# unique(unlist(lapply(strsplit(.getstructure(fid, paste0(timeStep, "/clusters/mcInd/structure"))$cluster, "/"), function(X)X[1]))) +# } -.getElements <- function(opts, tables, fid, timeStep){ - elements <- list() - if ("areas" %in% tables) elements$areas <- opts$areaList - if ("links" %in% tables) elements$links <- opts$linkList - if ("districts" %in% tables) elements$districts <- opts$districtList - if ("clusters" %in% tables){ - elements$clusters <- .getClustersNames(fid, timeStep) - } - elements -} +# .getElements <- function(opts, tables, fid, timeStep){ +# elements <- list() +# if ("areas" %in% tables) elements$areas <- opts$areaList +# if ("links" %in% tables) elements$links <- opts$linkList +# if ("districts" %in% tables) elements$districts <- opts$districtList +# if ("clusters" %in% tables){ +# elements$clusters <- .getClustersNames(fid, timeStep) +# } +# elements +# } +# +# .getDateRange <- function(opts, timeStep){ +# tim <- .timeIdToDate(sort( +# unique( +# antaresRead::.h5ReadAntares(opts$h5path, timeStep = timeStep, select = "timeId", +# areas = opts$areaList[1], mcYears = opts$mcYears[1], perf = FALSE)$timeId) +# ), timeStep = timeStep, opts = opts) +# dt <- as.Date(range(tim)) +# dt +# } +# +# +# .getGraphFunction <- function(type){ +# switch(type, +# "ts" = .plotTS, +# "barplot" = .barplot, +# "monotone" = .plotMonotone, +# "density" = .density, +# "cdf" = .cdf, +# "heatmap" = .heatmap, +# stop("Invalid type") +# ) +# } -.getDateRange <- function(opts, timeStep){ - tim <- .timeIdToDate(sort( - unique( - antaresRead::.h5ReadAntares(opts$h5path, timeStep = timeStep, select = "timeId", - areas = opts$areaList[1], mcYears = opts$mcYears[1], perf = FALSE)$timeId) - ), timeStep = timeStep, opts = opts) - dt <- as.Date(range(tim)) - dt -} - - -.getGraphFunction <- function(type){ - switch(type, - "ts" = .plotTS, - "barplot" = .barplot, - "monotone" = .plotMonotone, - "density" = .density, - "cdf" = .cdf, - "heatmap" = .heatmap, - stop("Invalid type") - ) -} - -.getTimeStep <- function(fid){ - timeSteps <- sapply(c("hourly", "daily", "weekly", "monthly", "annual"), function(X){ - rhdf5::H5Lexists(fid, X) - }) - names(timeSteps[which(timeSteps == TRUE)]) -} +# .getTimeStep <- function(fid){ +# timeSteps <- sapply(c("hourly", "daily", "weekly", "monthly", "annual"), function(X){ +# rhdf5::H5Lexists(fid, X) +# }) +# names(timeSteps[which(timeSteps == TRUE)]) +# } .compareOperation <- function(a, opType){ if (length(a) == 1) return(unlist(unique(a))) diff --git a/R/h5_utils_plot.R b/R/h5_utils_plot.R index fd2418b4..5b8e0720 100644 --- a/R/h5_utils_plot.R +++ b/R/h5_utils_plot.R @@ -1,20 +1,20 @@ -.getstructure <- function(fid, strgp){ - gid <- rhdf5::H5Gopen(fid, strgp) - data <- rhdf5::h5dump(gid) - rhdf5::H5Gclose(gid) - if(length(which(data$reCalcVar!="")) > 0) - { - data$reCalcVar <- data$reCalcVar[which(data$reCalcVar!="")] - data$variable <- c(data$variable, data$reCalcVar) - data$reCalcVar <- NULL - } - data -} - -.tryCloseH5 <- function(){ - try(rhdf5::H5close(), silent = TRUE) -} +# .getstructure <- function(fid, strgp){ +# gid <- rhdf5::H5Gopen(fid, strgp) +# data <- rhdf5::h5dump(gid) +# rhdf5::H5Gclose(gid) +# if(length(which(data$reCalcVar!="")) > 0) +# { +# data$reCalcVar <- data$reCalcVar[which(data$reCalcVar!="")] +# data$variable <- c(data$variable, data$reCalcVar) +# data$reCalcVar <- NULL +# } +# data +# } +# +# .tryCloseH5 <- function(){ +# try(rhdf5::H5close(), silent = TRUE) +# } diff --git a/R/map.R b/R/map.R index 9cbba1bd..9dea34c1 100644 --- a/R/map.R +++ b/R/map.R @@ -8,11 +8,11 @@ #' #' @param x #' Object of class \code{antaresDataList} created with -#' \code{\link[antaresRead]{readAntares}} and containing areas and links data. +#' [antaresRead::readAntares()] and containing areas and links data. #' It can be a list of \code{antaresData} objects. #' In this case, one chart is created for each object. #' @param mapLayout -#' Object created with function \code{\link{mapLayout}} +#' Object created with function [antaresViz::mapLayout()] #' @param colAreaVar #' Name of a variable present in \code{x$areas}. The values of this variable #' are represented by the color of the areas on the map. If \code{"none"}, then @@ -28,7 +28,7 @@ #' \code{logical}. Select \code{sizeAreaVars} using alias ? Default to \code{FALSE} #' @param aliasSizeAreaVars #' If \code{typeSizeAreaVars} is set to TRUE, name of alias. You can find the list -#' of alias with the function \code{\link[antaresRead]{showAliases}} +#' of alias with the function [antaresRead::showAliases()] #' @param areaChartType #' If parameter \code{sizeAreaVars} contains multiple variables, this parameter #' determines the type of representation. Possible values are \code{"bar"} for @@ -70,12 +70,12 @@ #' Title of the map. #' @param options #' List of parameters that override some default visual settings. See the -#' help of \code{\link{plotMapOptions}}. +#' help of [antaresViz::plotMapOptions()]. #' @param sizeMiniPlot \code{boolean} variable size for miniplot #' @param h5requestFiltering Contains arguments used by default for h5 request, #' typically h5requestFiltering = list(mcYears = 3) #' @inheritParams prodStack -#' +#' @importFrom lifecycle is_present deprecate_warn deprecated #' #' @details #' @@ -181,14 +181,30 @@ plotMap <- function(x, compareOpts = list(), interactive = getInteractivity(), options = plotMapOptions(), - width = NULL, height = NULL, dateRange = NULL, xyCompare = c("union","intersect"), - h5requestFiltering = list(), - timeSteph5 = "hourly", - mcYearh5 = NULL, - tablesh5 = c("areas", "links"), + width = NULL, + height = NULL, + dateRange = NULL, + xyCompare = c("union","intersect"), + h5requestFiltering = deprecated(), + timeSteph5 = deprecated(), + mcYearh5 = deprecated(), + tablesh5 = deprecated(), sizeMiniPlot = FALSE,language = "en", hidden = NULL, ...) { + deprecated_vector_params <- c(lifecycle::is_present(h5requestFiltering), + lifecycle::is_present(timeSteph5), + lifecycle::is_present(mcYearh5), + lifecycle::is_present(tablesh5)) + + if(any(deprecated_vector_params)) + lifecycle::deprecate_warn( + when = "0.18.1", + what = "plotMap(h5requestFiltering)", + details = "all these parameters are relative to the 'rhdf5' package, + which is removed from the dependencies" + ) + .check_x(x) .check_compare_interactive(compare, interactive) @@ -251,7 +267,7 @@ plotMap <- function(x, } # .testXclassAndInteractive(x, interactive) - h5requestFiltering <- .convertH5Filtering(h5requestFiltering = h5requestFiltering, x = x) + # h5requestFiltering <- .convertH5Filtering(h5requestFiltering = h5requestFiltering, x = x) compareOptions <- .compOpts(x, compare) @@ -512,15 +528,15 @@ plotMap <- function(x, if (!interactive) { - listParamH5NoInt <- list( - timeSteph5 = timeSteph5, - mcYearh5 = mcYearh5, - tablesh5 = tablesh5, - h5requestFiltering = h5requestFiltering - ) + # listParamH5NoInt <- list( + # timeSteph5 = timeSteph5, + # mcYearh5 = mcYearh5, + # tablesh5 = tablesh5, + # h5requestFiltering = h5requestFiltering + # ) params <- .getParamsNoInt(x = x, refStudy = refStudy, - listParamH5NoInt = listParamH5NoInt, + listParamH5NoInt = NULL, compare = compare, compareOptions = compareOptions, processFun = processFun, @@ -560,7 +576,7 @@ plotMap <- function(x, { if(!is.null(params)) { - .tryCloseH5() + # .tryCloseH5() # udpate for mw 0.11 & 0.10.1 if(!is.null(params)){ ind <- .id %% length(params$x) @@ -617,82 +633,82 @@ plotMap <- function(x, .giveListFormat(x) }), - h5requestFiltering = mwSharedValue({h5requestFiltering}), + # h5requestFiltering = mwSharedValue({h5requestFiltering}), - paramsH5 = mwSharedValue({ - paramsH5List <- .h5ParamList(X_I = x_in, xyCompare = xyCompare, h5requestFilter = h5requestFiltering) - rhdf5::H5close() - paramsH5List - }), - H5request = mwGroup( - label = .getLabelLanguage("H5request", language), - timeSteph5 = mwSelect( - { - if(length(paramsH5) > 0){ - choices = paramsH5$timeStepS - names(choices) <- sapply(choices, function(x) .getLabelLanguage(x, language)) - } else { - choices <- NULL - } - choices - }, - value = paramsH5$timeStepS[1], - label = .getLabelLanguage("timeStep", language), - multiple = FALSE, .display = !"timeSteph5" %in% hidden - ), - tables = mwSelect( - { - if(length(paramsH5) > 0){ - choices = paramsH5[["tabl"]][paramsH5[["tabl"]] %in% c("areas", "links")] - names(choices) <- sapply(choices, function(x) .getLabelLanguage(x, language)) - } else { - choices <- NULL - } - choices - }, - value = { - if(.initial) {paramsH5[["tabl"]][paramsH5[["tabl"]] %in% c("areas", "links")]} else {NULL} - }, - label = .getLabelLanguage("table", language), multiple = TRUE, - .display = !"tables" %in% hidden - ), - mcYearH5 = mwSelectize( - choices = { - ch <- c("Average" = "", paramsH5[["mcYearS"]]) - names(ch)[1] <- .getLabelLanguage("Average", language) - ch - }, - value = { - if(.initial){paramsH5[["mcYearS"]][1]}else{NULL} - }, - label = .getLabelLanguage("mcYears to be imported", language), - multiple = TRUE, options = list(maxItems = 4), - .display = (!"mcYearH5" %in% hidden & !meanYearH5) - ), - meanYearH5 = mwCheckbox(value = FALSE, - label = .getLabelLanguage("Average mcYear", language), - .display = !"meanYearH5" %in% hidden), - .display = {any(unlist(lapply(x_in, .isSimOpts))) & !"H5request" %in% hidden} - ), - sharerequest = mwSharedValue({ - if(length(meanYearH5) > 0){ - if(meanYearH5){ - list(timeSteph5_l = timeSteph5, mcYearh_l = NULL, tables_l = tables) - } else { - list(timeSteph5_l = timeSteph5, mcYearh_l = mcYearH5, tables_l = tables) - } - } else { - list(timeSteph5_l = timeSteph5, mcYearh_l = mcYearH5, tables_l = tables) - } - }), - x_tranform = mwSharedValue({ - resXT <- .get_x_transform(x_in = x_in, - sharerequest = sharerequest, - refStudy = refStudy, - h5requestFilter = paramsH5$h5requestFilter ) - resXT - - }), + # paramsH5 = mwSharedValue({ + # paramsH5List <- .h5ParamList(X_I = x_in, xyCompare = xyCompare, h5requestFilter = h5requestFiltering) + # rhdf5::H5close() + # paramsH5List + # }), + # H5request = mwGroup( + # label = .getLabelLanguage("H5request", language), + # timeSteph5 = mwSelect( + # { + # if(length(paramsH5) > 0){ + # choices = paramsH5$timeStepS + # names(choices) <- sapply(choices, function(x) .getLabelLanguage(x, language)) + # } else { + # choices <- NULL + # } + # choices + # }, + # value = paramsH5$timeStepS[1], + # label = .getLabelLanguage("timeStep", language), + # multiple = FALSE, .display = !"timeSteph5" %in% hidden + # ), + # tables = mwSelect( + # { + # if(length(paramsH5) > 0){ + # choices = paramsH5[["tabl"]][paramsH5[["tabl"]] %in% c("areas", "links")] + # names(choices) <- sapply(choices, function(x) .getLabelLanguage(x, language)) + # } else { + # choices <- NULL + # } + # choices + # }, + # value = { + # if(.initial) {paramsH5[["tabl"]][paramsH5[["tabl"]] %in% c("areas", "links")]} else {NULL} + # }, + # label = .getLabelLanguage("table", language), multiple = TRUE, + # .display = !"tables" %in% hidden + # ), + # mcYearH5 = mwSelectize( + # choices = { + # ch <- c("Average" = "", paramsH5[["mcYearS"]]) + # names(ch)[1] <- .getLabelLanguage("Average", language) + # ch + # }, + # value = { + # if(.initial){paramsH5[["mcYearS"]][1]}else{NULL} + # }, + # label = .getLabelLanguage("mcYears to be imported", language), + # multiple = TRUE, options = list(maxItems = 4), + # .display = (!"mcYearH5" %in% hidden & !meanYearH5) + # ), + # meanYearH5 = mwCheckbox(value = FALSE, + # label = .getLabelLanguage("Average mcYear", language), + # .display = !"meanYearH5" %in% hidden), + # .display = {any(unlist(lapply(x_in, .isSimOpts))) & !"H5request" %in% hidden} + # ), + # sharerequest = mwSharedValue({ + # if(length(meanYearH5) > 0){ + # if(meanYearH5){ + # list(timeSteph5_l = timeSteph5, mcYearh_l = NULL, tables_l = tables) + # } else { + # list(timeSteph5_l = timeSteph5, mcYearh_l = mcYearH5, tables_l = tables) + # } + # } else { + # list(timeSteph5_l = timeSteph5, mcYearh_l = mcYearH5, tables_l = tables) + # } + # }), + # x_tranform = mwSharedValue({ + # resXT <- .get_x_transform(x_in = x_in, + # sharerequest = sharerequest, + # refStudy = refStudy, + # h5requestFilter = paramsH5$h5requestFilter ) + # resXT + # + # }), ##Stop h5 mcYear = mwSelect( diff --git a/R/map_layout.R b/R/map_layout.R index 8509562d..68efd8ee 100644 --- a/R/map_layout.R +++ b/R/map_layout.R @@ -8,19 +8,19 @@ #' study. The result should then be saved in an external file and be reused. #' #' @param layout -#' object returned by function \code{\link[antaresRead]{readLayout}} +#' object returned by function [antaresRead::readLayout()] #' @param what #' Either "areas" or "districts". Indicates what type of object to place #' on the map. #' @param map -#' An optional \code{\link[sp]{SpatialPolygons}} or -#' \code{\link[sp:SpatialPolygons]{SpatialPolygonsDataFrame}} object. See \code{\link[spMaps:spMaps]{getSpMaps}} +#' An optional [sp::SpatialPolygons()] or +#' [sp::SpatialPolygonsDataFrame()] object. See [spMaps::getSpMaps()] #' #' @param map_builder \code{logical} Add inputs for build custom map ? Defaut to TRUE. #' #' @details #' With \code{map_builder} option, you can build a quiet custom map using \code{spMaps} package. -#' This package help you to build \code{\link[sp:SpatialPolygons]{SpatialPolygonsDataFrame}} on Europe. +#' This package help you to build [sp::SpatialPolygons()] on Europe. #' Moreover, you can use two options in the module : #' #' \itemize{ @@ -51,7 +51,7 @@ #' @export #' @import spMaps #' -#' @seealso \code{\link{plotMapLayout}} +#' @seealso [plotMapLayout()] mapLayout <- function(layout, what = c("areas", "districts"), map = getSpMaps(), map_builder = TRUE) { what <- match.arg(what) @@ -73,7 +73,7 @@ mapLayout <- function(layout, what = c("areas", "districts"), map = getSpMaps(), #' Visualize mapLayout output. #' #' @param mapLayout -#' object returned by function \code{\link{mapLayout}} +#' object returned by function [mapLayout()] #' #' @examples #' @@ -90,7 +90,7 @@ mapLayout <- function(layout, what = c("areas", "districts"), map = getSpMaps(), #' #' @export #' -#' @seealso \code{\link{mapLayout}} +#' @seealso [mapLayout()] plotMapLayout <- function(mapLayout){ if (!is.null(mapLayout$all_coords)){ @@ -513,10 +513,10 @@ changeCoordsServer <- function(input, output, session, #' #' This method can be used to visualize the network of an antares study. #' It generates an interactive map with a visual representaiton of a -#' map layout created with function \code{\link{mapLayout}}. +#' map layout created with function [mapLayout()]. #' #' @param x -#' Object created with function \code{\link{mapLayout}} +#' Object created with function [mapLayout()] #' @param colAreas #' Vector of colors for areas. By default, the colors used in the Antares #' software are used. @@ -554,7 +554,7 @@ changeCoordsServer <- function(input, output, session, #' @return #' The function generates an \code{htmlwidget} of class \code{leaflet}. It can #' be stored in a variable and modified with package -#' \code{\link[leaflet]{leaflet}} +#' [leaflet::leaflet()] #' #' @method plot mapLayout #' diff --git a/R/map_options.R b/R/map_options.R index ccbb66b5..e82740c9 100644 --- a/R/map_options.R +++ b/R/map_options.R @@ -3,7 +3,7 @@ #' Graphical options for plotMap #' #' These functions get and set options that control some graphical aspects -#' of maps created with \code{\link{plotMap}}. +#' of maps created with [plotMap()]. #' #' @param areaDefaultCol #' default color of areas. diff --git a/R/mod_XY.R b/R/mod_XY.R index 4780ca47..0176af2f 100644 --- a/R/mod_XY.R +++ b/R/mod_XY.R @@ -45,11 +45,11 @@ modXY <- function(x, xyCompare = c("union","intersect")) x_in = mwSharedValue({ .giveListFormat(x) }), - paramsH5 = mwSharedValue({ - paramsH5List <- .h5ParamList(X_I = x_in, xyCompare = xyCompare) - rhdf5::H5close() - paramsH5List - }), + # paramsH5 = mwSharedValue({ + # paramsH5List <- .h5ParamList(X_I = x_in, xyCompare = xyCompare) + # rhdf5::H5close() + # paramsH5List + # }), H5request = mwGroup( timeSteph5 = mwSelect(choices = paramsH5$timeStepS, value = paramsH5$timeStepS[1], diff --git a/R/mod_rpart.R b/R/mod_rpart.R index 4fdb34aa..bd634f85 100644 --- a/R/mod_rpart.R +++ b/R/mod_rpart.R @@ -2,7 +2,7 @@ #' Make rpart from antares data #' -#' @param data an antaresData after use of \code{\link[antaresProcessing]{mergeAllAntaresData}} +#' @param data an antaresData after use of [antaresProcessing::mergeAllAntaresData] #' #' @examples #' \dontrun{ diff --git a/R/plot.R b/R/plot.R index 6530131b..410922ac 100644 --- a/R/plot.R +++ b/R/plot.R @@ -61,7 +61,7 @@ #' Label of the Y axis. #' @param colorScaleOpts #' A list of parameters that control the creation of color scales. It is used -#' only for heatmaps. See \code{\link{colorScaleOptions}}() for available +#' only for heatmaps. See [colorScaleOptions()] for available #' parameters. #' @param xyCompare #' Use when you compare studies, can be "union" or "intersect". If union, all @@ -106,7 +106,6 @@ #' #' @examples #' \dontrun{ -#' setSimulationPath(path = path1) #' mydata <- readAntares(areas = "all", timeStep = "hourly") #' plot(x = mydata) #' @@ -170,8 +169,9 @@ #' # Compare 2 studies with argument refStudy #' plot(x = opts, refStudy = opts2) #' plot(x = opts, refStudy = opts2, type = "ts", interactive = FALSE, mcYearh5 = 2) -#' plot(x = opts, refStudy = opts2, type = "ts", dateRange = DR, h5requestFiltering = list( -#' mcYears = mcYears = mcYearToTest)) +#' plot(x = opts, refStudy = opts2, type = "ts", +#' dateRange = DR, +#' h5requestFiltering = list(mcYears = mcYears = mcYearToTest)) #' #' #' } @@ -204,13 +204,38 @@ tsPlot <- function(x, legendItemsPerRow = 5, colorScaleOpts = colorScaleOptions(20), width = NULL, height = NULL, xyCompare = c("union","intersect"), - h5requestFiltering = list(), highlight = FALSE, stepPlot = FALSE, drawPoints = FALSE, + h5requestFiltering = deprecated(), highlight = FALSE, stepPlot = FALSE, drawPoints = FALSE, secondAxis = FALSE, - timeSteph5 = "hourly", - mcYearh5 = NULL, - tablesh5 = c("areas", "links"), language = "en", + timeSteph5 = deprecated(), + mcYearh5 = deprecated(), + tablesh5 = deprecated(), language = "en", hidden = NULL, ...) { + deprecated_vector_params <- c(lifecycle::is_present(h5requestFiltering), + lifecycle::is_present(timeSteph5), + lifecycle::is_present(mcYearh5), + lifecycle::is_present(tablesh5)) + + if(any(deprecated_vector_params)){ + lifecycle::deprecate_warn( + when = "0.18.1", + what = "tsPlot(h5requestFiltering)", + details = "all these parameters are relative to the 'rhdf5' package, + which is removed from the dependencies" + ) + + h5requestFiltering <- NULL + timeSteph5 <- NULL + mcYearh5 <- NULL + tablesh5 <- NULL + } + + # force (deprecated) + h5requestFiltering <- NULL + timeSteph5 <- NULL + mcYearh5 <- NULL + tablesh5 <- NULL + .check_x(x) .check_compare_interactive(compare, interactive) @@ -258,7 +283,7 @@ tsPlot <- function(x, } # .testXclassAndInteractive(x, interactive) - h5requestFiltering <- .convertH5Filtering(h5requestFiltering = h5requestFiltering, x = x) + # h5requestFiltering <- .convertH5Filtering(h5requestFiltering = h5requestFiltering, x = x) # Generate a group number for dygraph objects @@ -478,7 +503,7 @@ tsPlot <- function(x, meanYearH5 <- NULL manipulateWidget({ - .tryCloseH5() + # .tryCloseH5() # udpate for mw 0.11 & 0.10.1 if(!is.null(params)){ @@ -531,9 +556,9 @@ tsPlot <- function(x, h5requestFiltering = mwSharedValue({h5requestFiltering}), - paramsH5 = mwSharedValue({ - .h5ParamList(X_I = x_in, xyCompare = xyCompare, h5requestFilter = h5requestFiltering) - }), + # paramsH5 = mwSharedValue({ + # .h5ParamList(X_I = x_in, xyCompare = xyCompare, h5requestFilter = h5requestFiltering) + # }), H5request = mwGroup( label = .getLabelLanguage("H5request", language), diff --git a/R/plot_utils.R b/R/plot_utils.R index 67e78438..56a8b9db 100644 --- a/R/plot_utils.R +++ b/R/plot_utils.R @@ -214,7 +214,7 @@ listParamsCheck$x <- list(listParamsCheck$x, listParamsCheck$x) } - listParamsCheck$h5requestFiltering <- .convertH5Filtering(h5requestFiltering = listParamsCheck$h5requestFiltering, x = listParamsCheck$x) + # listParamsCheck$h5requestFiltering <- .convertH5Filtering(h5requestFiltering = listParamsCheck$h5requestFiltering, x = listParamsCheck$x) listParamsCheck$compareOptions <- .compOpts(listParamsCheck$x, listParamsCheck$compare) if (is.null(listParamsCheck$compare)){ diff --git a/R/savePlotAsPng.R b/R/savePlotAsPng.R index 76ea316e..6f57d9ed 100644 --- a/R/savePlotAsPng.R +++ b/R/savePlotAsPng.R @@ -13,7 +13,7 @@ #' @param height #' height of the output file #' @param ... -#' Other parameters passed to function \code{\link[webshot]{webshot}} +#' Other parameters passed to function [webshot::webshot] #' #' @return #' The function only creates the required file. Nothing is returned diff --git a/R/stack_exchanges.R b/R/stack_exchanges.R index 553b73c5..8d4ff3ad 100644 --- a/R/stack_exchanges.R +++ b/R/stack_exchanges.R @@ -11,7 +11,7 @@ #' #' @param x #' Object of class \code{antaresData} created with function -#' \code{\link[antaresRead]{readAntares}}. It is required to contain link data. +#' [antaresRead::readAntares]. It is required to contain link data. #' If it also contains area data with column `ROW BAL.`, then exchanges with #' the rest of the world are also displayed on the chart. #' @param stack @@ -107,15 +107,41 @@ exchangesStack <- function(x, legendItemsPerRow = 5, width = NULL, height = NULL, xyCompare = c("union", "intersect"), - h5requestFiltering = list(), + h5requestFiltering = deprecated(), stepPlot = FALSE, drawPoints = FALSE, - timeSteph5 = "hourly", - mcYearh5 = NULL, - tablesh5 = c("areas", "links"), + timeSteph5 = deprecated(), + mcYearh5 = deprecated(), + tablesh5 = deprecated(), language = "en", hidden = NULL, refStudy = NULL, ...) { + + deprecated_vector_params <- c(lifecycle::is_present(h5requestFiltering), + lifecycle::is_present(timeSteph5), + lifecycle::is_present(mcYearh5), + lifecycle::is_present(tablesh5)) + + if(any(deprecated_vector_params)){ + lifecycle::deprecate_warn( + when = "0.18.1", + what = "exchangesStack(h5requestFiltering)", + details = "all these parameters are relative to the 'rhdf5' package, + which is removed from the dependencies" + ) + + h5requestFiltering <- NULL + timeSteph5 <- NULL + mcYearh5 <- NULL + tablesh5 <- NULL + } + + # force (deprecated) + h5requestFiltering <- NULL + timeSteph5 <- NULL + mcYearh5 <- NULL + tablesh5 <- NULL + #we can hide these values exchangesStackValHidden <- c("H5request", "timeSteph5", "mcYearhH5", "mcYear", "main", @@ -385,7 +411,7 @@ exchangesStack <- function(x, manipulateWidget( { - .tryCloseH5() + # .tryCloseH5() # udpate for mw 0.11 & 0.10.1 if(!is.null(params)){ ind <- .id %% length(params$x) @@ -404,9 +430,9 @@ exchangesStack <- function(x, .giveListFormat(x) }), - paramsH5 = mwSharedValue({ - .h5ParamList(X_I = x_in, xyCompare = xyCompare, h5requestFilter = h5requestFiltering) - }), + # paramsH5 = mwSharedValue({ + # .h5ParamList(X_I = x_in, xyCompare = xyCompare, h5requestFilter = h5requestFiltering) + # }), H5request = mwGroup( label = .getLabelLanguage("H5request", language), diff --git a/R/stack_map.R b/R/stack_map.R index 4407bd2c..9edad46c 100644 --- a/R/stack_map.R +++ b/R/stack_map.R @@ -6,7 +6,7 @@ #' #' @param x \code{antaresDataList} antaresDataList contian areas ans links. #' @param mapLayout -#' Object created with function \code{\link{mapLayout}} +#' Object created with function [mapLayout()] #' #' @examples #' \dontrun{ diff --git a/R/stack_prod.R b/R/stack_prod.R index 6a4a541d..d249369d 100644 --- a/R/stack_prod.R +++ b/R/stack_prod.R @@ -8,13 +8,13 @@ #' #' @param x #' An object of class \code{antaresData} created with function -#' \code{\link[antaresRead]{readAntares}} containing data for areas and or +#' [antaresRead::readAntares()] containing data for areas and or #' districts. it can be a list of \code{antaresData} objects. #' In this case, one chart is created for each object. #' Can also contains opts who refer to a h5 file or list of opts. #' @param refStudy #' An object of class \code{antaresData} created with function -#' \code{\link[antaresRead]{readAntares}} containing data for areas and or +#' [antaresRead::readAntares()] containing data for areas and or #' districts. Can also contains an opts who refer to a h5 file. #' @param stack #' Name of the stack to use. One can visualize available stacks with @@ -49,7 +49,7 @@ #' @param compareOpts #' List of options that indicates the number of charts to create and their #' position. Check out the documentation of -#' \code{\link[manipulateWidget]{compareOptions}} to see available options. +#' [manipulateWidget::compareOptions] to see available options. #' @param width #' Width of the graph expressed in pixels or in percentage of #' the parent element. For instance "500px" and "100\%" are valid values. @@ -62,10 +62,10 @@ #' @param legend #' Logical value indicating if a legend should be drawn. This argument is #' usefull when one wants to create a shared legend with -#' \code{\link{prodStackLegend}} +#' [prodStackLegend()] #' @param legendId Id of the legend linked to the graph. This argument is #' usefull when one wants to create a shared legend with -#' \code{\link{prodStackLegend}} +#' [prodStackLegend()] #' @param groupId Parameter that can be used to synchronize the horizontal #' zoom of multiple charts. All charts that need to be synchronized must #' have the same group. @@ -76,7 +76,7 @@ #' @param name #' name of the stack to create or update #' @param variables -#' A named list of expressions created with \code{\link[base:list]{alist}}. The +#' A named list of expressions created with [base::alist]. The #' name of each element is the name of the variable to draw in the stacked #' graph. The element itself is an expression explaining how to compute the #' variable (see examples). @@ -85,7 +85,7 @@ #' \code{variables} is an alias, then this argument should be \code{NULL} in #' order to use default colors. #' @param lines -#' A named list of expressions created with \code{\link[base:list]{alist}} +#' A named list of expressions created with [base::alist] #' indicating how to compute the curves to display on top of the stacked graph. #' It should be \code{NULL} if there is no curve to trace or if parameter #' \code{variables} is an alias. @@ -111,7 +111,7 @@ #' @param tablesh5 \code{character} tables for h5 ("areas" "links", "clusters" or "disticts"). Only for Non interactive mode. #' @param language \code{character} language use for label. Defaut to 'en'. Can be 'fr'. #' @param hidden \code{logical} Names of input to hide. Defaut to NULL -#' @param ... Other arguments for \code{\link{manipulateWidget}} +#' @param ... Other arguments for [manipulateWidget::manipulateWidget] #' #' @return #' \code{prodStack} returns an interactive html graphic. If argument @@ -123,7 +123,7 @@ #' #' \code{setProdStackAlias} creates or updates a stack alias. #' -#' @seealso \code{\link{prodStackLegend}} +#' @seealso [prodStackLegend()] #' #' @details #' compare argument can take following values : @@ -233,14 +233,38 @@ prodStack <- function(x, updateLegendOnMouseOver = TRUE, legendItemsPerRow = 5, width = NULL, height = NULL, xyCompare = c("union", "intersect"), - h5requestFiltering = list(), stepPlot = FALSE, drawPoints = FALSE, - timeSteph5 = "hourly", - mcYearh5 = NULL, - tablesh5 = c("areas", "links"), language = "en", + h5requestFiltering = deprecated(), stepPlot = FALSE, drawPoints = FALSE, + timeSteph5 = deprecated(), + mcYearh5 = deprecated(), + tablesh5 = deprecated(), language = "en", hidden = NULL, refStudy = NULL, ...) { + deprecated_vector_params <- c(lifecycle::is_present(h5requestFiltering), + lifecycle::is_present(timeSteph5), + lifecycle::is_present(mcYearh5), + lifecycle::is_present(tablesh5)) + + if(any(deprecated_vector_params)){ + lifecycle::deprecate_warn( + when = "0.18.1", + what = "prodStack(h5requestFiltering)", + details = "all these parameters are relative to the 'rhdf5' package, + which is removed from the dependencies" + ) + + h5requestFiltering <- NULL + timeSteph5 <- NULL + mcYearh5 <- NULL + tablesh5 <- NULL + } + + # force (deprecated) + h5requestFiltering <- NULL + timeSteph5 <- NULL + mcYearh5 <- NULL + tablesh5 <- NULL #we can hide these values prodStackValHidden <- c("H5request", "timeSteph5", "tables", "mcYearH5", "mcYear", "main", "dateRange", @@ -436,7 +460,7 @@ prodStack <- function(x, manipulateWidget( { - .tryCloseH5() + # .tryCloseH5() # udpate for mw 0.11 & 0.10.1 if(!is.null(params)){ @@ -458,11 +482,11 @@ prodStack <- function(x, h5requestFiltering = mwSharedValue({ h5requestFiltering }), - paramsH5 = mwSharedValue({ - tmp <- .h5ParamList(X_I = x_in, xyCompare = xyCompare, - h5requestFilter = h5requestFiltering) - tmp - }), + # paramsH5 = mwSharedValue({ + # tmp <- .h5ParamList(X_I = x_in, xyCompare = xyCompare, + # h5requestFilter = h5requestFiltering) + # tmp + # }), H5request = mwGroup( label = .getLabelLanguage("H5request", language), timeSteph5 = mwSelect( diff --git a/R/zzz.R b/R/zzz.R index d3fdac69..5e9438f7 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -29,7 +29,6 @@ globalVariables( .timeIdToDate <- antaresRead:::.timeIdToDate .getTimeId <- antaresRead:::.getTimeId .mergeByRef <- antaresRead:::.mergeByRef -.requireRhdf5_Antares <- antaresRead:::.requireRhdf5_Antares .checkColumns <- antaresProcessing:::.checkColumns .checkAttrs <- antaresProcessing:::.checkAttrs @@ -279,70 +278,50 @@ colorsVars <- unique(rbindlist(list(colorsVars, col_fr))) return(resList) } -#' edit h5 file only for TEST -#' currently only for hourly data and areas -#' -#' @param pathH5 path H5 file -#' @param area character -#' @param timeId timeId to change -#' @param antVar antares Variable to change -#' @param newValue the newValue -#' -#' @noRd -.h5Antares_edit_variable <- function(pathH5 = NULL, area = NULL, timeId = 1, antVar = NULL, newValue = NULL, mcYear = NULL, link = NULL){ - - if (!is.null(area) & !is.null(link)){ - stop("area and link must not be set together") - } - - if (!is.null(area)){ - categoryVar <- "areas" - }else{ - categoryVar <- "links" - } - - if (is.null(mcYear)){ - typeOfData <- "/mcAll" - }else{ - typeOfData <- "/mcInd" - } - timeStepType <- paste("/hourly", categoryVar, sep = "/") - nameStructure <- paste0(timeStepType, typeOfData, "/structure") - - H5locAntaresh5 <- rhdf5::H5Fopen(name = pathH5) - hourlyDataStructure <- rhdf5::h5read(H5locAntaresh5, name = nameStructure) - - if (!is.null(area)){ - indexCateroryInstance <- grep(area, hourlyDataStructure$area)[1] - }else{ - indexCateroryInstance <- grep(link, hourlyDataStructure$link)[1] - } - - indexAntVar <- grep(antVar, hourlyDataStructure$variable)[1] - indexTimeId <- timeId - if (is.null(mcYear)){ - indexMcYear <- 1 - }else{ - indexMcYear <- grep(mcYear, hourlyDataStructure$mcYear)[1] - } - - listIndex <- list(indexTimeId, indexAntVar, indexCateroryInstance, indexMcYear) - #debug print(listIndex) - - hourlyData <- rhdf5::h5read( - H5locAntaresh5, - name = paste0(timeStepType, typeOfData, "/data"), - index = listIndex) - - hourlyData[,,,] <- newValue - - rhdf5::h5writeDataset( - obj = hourlyData, - h5loc = H5locAntaresh5, - name = paste0(timeStepType, typeOfData, "/data"), - index = listIndex - ) - - rhdf5::H5Fclose(h5file = H5locAntaresh5) - rhdf5::h5closeAll() -} +#' #' edit h5 file only for TEST +#' #' currently only for hourly data and areas +#' #' +#' #' @param pathH5 path H5 file +#' #' @param area character +#' #' @param timeId timeId to change +#' #' @param antVar antares Variable to change +#' #' @param newValue the newValue +#' #' +#' #' @noRd +#' .h5Antares_edit_variable <- function(pathH5 = NULL, area = NULL, timeId = 1, antVar = NULL, newValue = NULL, mcYear = NULL, link = NULL){ +#' +#' if (!is.null(area) & !is.null(link)){ +#' stop("area and link must not be set together") +#' } +#' +#' if (!is.null(area)){ +#' categoryVar <- "areas" +#' }else{ +#' categoryVar <- "links" +#' } +#' +#' if (is.null(mcYear)){ +#' typeOfData <- "/mcAll" +#' }else{ +#' typeOfData <- "/mcInd" +#' } +#' timeStepType <- paste("/hourly", categoryVar, sep = "/") +#' nameStructure <- paste0(timeStepType, typeOfData, "/structure") +#' +#' if (!is.null(area)){ +#' indexCateroryInstance <- grep(area, hourlyDataStructure$area)[1] +#' }else{ +#' indexCateroryInstance <- grep(link, hourlyDataStructure$link)[1] +#' } +#' +#' indexAntVar <- grep(antVar, hourlyDataStructure$variable)[1] +#' indexTimeId <- timeId +#' if (is.null(mcYear)){ +#' indexMcYear <- 1 +#' }else{ +#' indexMcYear <- grep(mcYear, hourlyDataStructure$mcYear)[1] +#' } +#' +#' listIndex <- list(indexTimeId, indexAntVar, indexCateroryInstance, indexMcYear) +#' #debug print(listIndex) +#' } diff --git a/cran-comments.md b/cran-comments.md index 9679632f..59d7ab8e 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -21,3 +21,13 @@ Flavor: r-devel-linux-x86_64-debian-gcc Check: tests, Result: NOTE Running 'testthat.R' [143s/16s] Running R code in 'testthat.R' had CPU time 8.9 times elapsed time + +## v0.18.1 +new version to fix pb with dependencies `AntaresRead` : + - "M1mac" issue + +We have to fix dependencies with package `rhdf5` on this package before to push `antaresRead` 2.7.1 + +## v0.18.2 +Cran check in ERROR cause test skip not skip + diff --git a/docs/404.html b/docs/404.html index f9409273..57c90e70 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1,163 +1,118 @@ - - - -
- - - - -