Skip to content

Commit

Permalink
fix for re submission
Browse files Browse the repository at this point in the history
  • Loading branch information
berthetclement committed Sep 26, 2024
1 parent c9e4aed commit 3e40a02
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
24 changes: 12 additions & 12 deletions R/computeTimeStepFromHourly.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
# First merge
alldaysYearTwo <- data.table(day = alldaysYearTwo, week2 = weekVector)
alldaysYearTwo[, year2 := year(day)]
res <- merge(copy(dailydata)[, time := as.Date(time)], alldaysYearTwo, by.x = "time", by.y = "day", all.x = T)
res <- merge(copy(dailydata)[, time := as.Date(time)], alldaysYearTwo, by.x = "time", by.y = "day", all.x = TRUE)

# Set up year One
alldaysYearOne <- seq(as.Date(paste0(year-1,"-01-01")),as.Date(paste0(year-1,"-12-31")),by="1 day")
Expand All @@ -144,7 +144,7 @@
# Second merge
alldaysYearOne <- data.table(day = alldaysYearOne, week1 = weekVector)
alldaysYearOne[, year1 := year(day)]
res <- merge(res, alldaysYearOne, by.x = "time", by.y = "day", all.x = T)
res <- merge(res, alldaysYearOne, by.x = "time", by.y = "day", all.x = TRUE)

res[, `:=` (week = ifelse(is.na(week1),week2,week1),
year = ifelse(is.na(year1),year2,year1))][, c("week1", "week2", "year1", "year2") := NULL]
Expand All @@ -156,12 +156,12 @@

if (length(colForMean) > 0){
resMean <- res[, lapply(.SD, function(x){round(mean(x),2)}),.SDcols = colForMean, by= agg_columns]
resFinal <- merge(resSum, resMean, by = agg_columns, sort = F)
resFinal <- merge(resSum, resMean, by = agg_columns, sort = FALSE)
} else resFinal <- resSum

if (length(colForMax) > 0){
resMean <- res[, lapply(.SD, max),.SDcols = colForMax, by= agg_columns]
resFinal <- merge(resFinal, resMean, by = agg_columns, sort = F)
resFinal <- merge(resFinal, resMean, by = agg_columns, sort = FALSE)
}

resFinal[, timeId := week]
Expand Down Expand Up @@ -192,24 +192,24 @@ computeOtherFromHourlyYear <- function(mcYear,
areas = "all",
opts = simOptions(),
timeStep = c("daily", "monthly", "annual", "weekly"),
writeOutput = F){
writeOutput = FALSE){
res <- list()
#for the eval(parse(text))
if (length(areas) == 1) selected <- ifelse(areas == "all", "areas", paste0("'",areas,"'"))
else if (type != "links") selected <- paste(list(areas), sep = ",")
else selected <- paste(list(getLinks(areas, internalOnly = T, opts = opts)),
else selected <- paste(list(getLinks(areas, internalOnly = TRUE, opts = opts)),
sep = ",")

formula <- sprintf('readAntares(%s = %s, timeStep = "hourly",
mcYears = mcYear, showProgress = F, opts = opts)',
mcYears = mcYear, showProgress = FALSE, opts = opts)',
type, selected) #read any type data
hourlydata <- eval(parse(text = formula))
if (type == "clustersRes" && length(hourlydata) > 1) hourlydata <- hourlydata$clustersRes

# Multi timestep at once
# steps <- as.list(intersect(c("daily", "monthly", "annual"), timeStep))
# res <- llply(steps, .hourlyToOther, hourlydata = hourlydata, type = type,
# .parallel = T, .paropts = list(preschedule=TRUE))
# .parallel = TRUE, .paropts = list(preschedule=TRUE))
# names(res) <- paste0(steps,"data")

# Separate timesteps
Expand Down Expand Up @@ -246,7 +246,7 @@ computeOtherFromHourlyYear <- function(mcYear,
}

lapply(res, writeOutputValues, opts = opts)
# llply(res, writeOutputValues, opts = opts, .parallel = T, .paropts = list(preschedule=TRUE))
# llply(res, writeOutputValues, opts = opts, .parallel = TRUE, .paropts = list(preschedule=TRUE))
}

res
Expand Down Expand Up @@ -283,12 +283,12 @@ computeOtherFromHourlyMulti <- function(opts = simOptions(),
type = c("areas", "links", "clusters"),
timeStep = c("daily", "monthly", "annual", "weekly"),
mcYears = simOptions()$mcYears,
writeOutput = F,
writeOutput = FALSE,
nbcl = 8,
verbose = F){
verbose = FALSE){

if (verbose){
handlers(global = T)
handlers(global = TRUE)
handlers("progress")
}

Expand Down
10 changes: 8 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ Failure ('test-createCluster.R:76:5'): Remove all clusters ───────
## antaresEditObject 0.6.4
Patch version to break abusive dependencies with antaresRead in tests

## antaresEditObject 0.7.2
Fix Cran Error :
## antaresEditObject 0.7.1

### Re Submission

- Check: PDF version of manual, Result: WARNING
LaTeX errors when creating PDF version.
Expand All @@ -51,3 +52,8 @@ Erreur : Cannot find the file(s): "../man/figures/badge_api_ok.svg"

This error did not appear on the CRAN

### Re Submission 2

- Fix TRUE and FALSE instead of T and F
- `\dontrun{}` sections are needed because most of functions need to be apply on a study load on Global env (legacy code too)

0 comments on commit 3e40a02

Please sign in to comment.