Skip to content

Commit

Permalink
clean reference to rhdf5 package EVERYWHERE
Browse files Browse the repository at this point in the history
  • Loading branch information
berthetclement committed Jun 25, 2024
1 parent f417014 commit 42a4aec
Show file tree
Hide file tree
Showing 15 changed files with 1,274 additions and 1,201 deletions.
72 changes: 36 additions & 36 deletions R/h5_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,43 +60,43 @@
# }, simplify = FALSE)
# }

.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
}

.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
}

# .getClustersNames <- function(fid, timeStep){
# unique(unlist(lapply(strsplit(.getstructure(fid, paste0(timeStep, "/clusters/mcInd/structure"))$cluster, "/"), function(X)X[1])))
# }

.getGraphFunction <- function(type){
switch(type,
"ts" = .plotTS,
"barplot" = .barplot,
"monotone" = .plotMonotone,
"density" = .density,
"cdf" = .cdf,
"heatmap" = .heatmap,
stop("Invalid type")
)
}
# .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")
# )
# }

# .getTimeStep <- function(fid){
# timeSteps <- sapply(c("hourly", "daily", "weekly", "monthly", "annual"), function(X){
Expand Down
10 changes: 5 additions & 5 deletions R/mod_XY.R
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
43 changes: 34 additions & 9 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -478,7 +503,7 @@ tsPlot <- function(x,
meanYearH5 <- NULL

manipulateWidget({
.tryCloseH5()
# .tryCloseH5()

# udpate for mw 0.11 & 0.10.1
if(!is.null(params)){
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion R/plot_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down
42 changes: 34 additions & 8 deletions R/stack_exchanges.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand All @@ -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),
Expand Down
44 changes: 34 additions & 10 deletions R/stack_prod.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -436,7 +460,7 @@ prodStack <- function(x,

manipulateWidget(
{
.tryCloseH5()
# .tryCloseH5()

# udpate for mw 0.11 & 0.10.1
if(!is.null(params)){
Expand All @@ -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(
Expand Down
Loading

0 comments on commit 42a4aec

Please sign in to comment.