Running 'testthat.R' [335s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > #Copyright Â© 2016 RTE RÃ©seau de transport dâÃ©lectricitÃ©
  > 
  > require(testthat)
  Loading required package: testthat
  > require(antaresRead)
  Loading required package: antaresRead
  > require(plyr)
  Loading required package: plyr
  > 
  > 
  > #Maybe include this in some test-file.R 
  > #is.solaris<-function(){
  > #  grepl('SunOS',Sys.info()['sysname'])
  > #}
  > 
  > #if(!is.solaris()){
  > 
  > test_check("antaresRead")
  -- 1. Error: nostat -NUCLEAR hourly (@test-h5ReadAntares.R#132)  ---------------
  cannot allocate vector of size 68 Kb
  1: suppressWarnings({
         do.call(readAntares, param1)
     }) at testthat/test-h5ReadAntares.R:132
  2: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
  3: do.call(readAntares, param1) at testthat/test-h5ReadAntares.R:132
  4: (function (areas = NULL, links = NULL, clusters = NULL, districts = NULL, misc = FALSE, 
         thermalAvailabilities = FALSE, hydroStorage = FALSE, hydroStorageMaxPower = FALSE, 
         reserve = FALSE, linkCapacity = FALSE, mustRun = FALSE, thermalModulation = FALSE, 
         select = NULL, mcYears = NULL, timeStep = c("hourly", "daily", "weekly", "monthly", 
             "annual"), opts = simOptions(), parallel = FALSE, simplify = TRUE, showProgress = TRUE) 
     {
         timeStep <- match.arg(timeStep)
         size <- .giveSize(opts = opts, areas = areas, links = links, clusters = clusters, 
             districts = districts, select = select, mcYears = mcYears, timeStep = timeStep, 
             misc = misc, thermalAvailabilities = thermalAvailabilities, hydroStorage = hydroStorage, 
             hydroStorageMaxPower = hydroStorageMaxPower, reserve = reserve, linkCapacity = linkCapacity, 
             mustRun = mustRun, thermalModulation = thermalModulation)/1024
         if (is.null(getOption("maxSizeLoadOnComp"))) {
             options(maxSizeLoadOnComp = utils::memory.limit() * 0.7/1000)
         }
         if (is.null(getOption("maxSizeLoad"))) {
             options(maxSizeLoad = 10)
         }
         if (getOption("maxSizeLoad") < size) {
             stop("You want to load more than 10Go of data,\n         if you want you can modify antaresRead rules of RAM control with setRam()")
         }
         if (getOption("maxSizeLoadOnComp") < size) {
             stop("You want to load more than 70% of your computer capacity,\n         if you want you can modify antaresRead rules of RAM control with setRam()")
         }
         if (!is.null(select)) {
             if (!is.list(select)) {
                 if ("all" %in% select) {
                     select <- c("all", select[!"all" == select])
                 }
             }
         }
         if (isH5Opts(opts)) {
             if (requireNamespace("rhdf5", versionCheck = list(op = ">=", version = "2.20.0"))) {
                 return(.h5ReadAntares(path = opts$h5path, areas = areas, links = links, 
                     clusters = clusters, districts = districts, misc = misc, thermalAvailabilities = thermalAvailabilities, 
                     hydroStorage = hydroStorage, hydroStorageMaxPower = hydroStorageMaxPower, 
                     reserve = reserve, linkCapacity = linkCapacity, mustRun = mustRun, 
                     thermalModulation = thermalModulation, select = select, mcYears = mcYears, 
                     timeStep = timeStep[1], showProgress = showProgress, simplify = simplify))
             }
             else {
                 stop(rhdf5_message)
             }
         }
         if (opts$mode == "Input") 
             stop("Cannot use 'readAntares' in 'Input' mode.")
         reqInfos <- .giveInfoRequest(select = select, areas = areas, links = links, clusters = clusters, 
             districts = districts, mcYears = mcYears)
         select <- reqInfos$select
         areas <- reqInfos$areas
         links <- reqInfos$links
         clusters <- reqInfos$clusters
         districts <- reqInfos$districts
         mcYears <- reqInfos$mcYears
         synthesis <- reqInfos$synthesis
         unselect <- reqInfos$unselect
         if (length(reqInfos$computeAdd) > 0) {
             for (v in reqInfos$computeAdd) {
                 assign(v, TRUE)
             }
         }
         if (is.null(areas) & is.null(links) & is.null(clusters) & is.null(districts)) {
             areas <- "all"
         }
         synthesis <- is.null(mcYears)
         areas <- .checkArg(areas, opts$areaList, "Areas %s do not exist in the simulation.")
         links <- .checkArg(links, opts$linkList, "Links %s do not exist in the simulation.")
         clusters <- .checkArg(clusters, opts$areasWithClusters, "Areas %s do not exist in the simulation or do not have any cluster.")
         districts <- .checkArg(districts, opts$districtList, "Districts %s do not exist in the simulation.")
         mcYears <- .checkArg(mcYears, opts$mcYears, "Monte-Carlo years %s have not been exported.", 
             allowDup = TRUE)
         select$areas <- if (any(grepl("allArea", select$areas, ignore.case = TRUE))) 
             NULL
         else select$areas
         select$links <- if (any(grepl("allLink", select$links, ignore.case = TRUE))) 
             NULL
         else select$links
         if ((is.null(areas) & is.null(districts)) & (misc | hydroStorage | hydroStorageMaxPower | 
             reserve)) {
             stop("When misc, hydroStorage, hydroStorageMaxPower or reserve is TRUE, arguments 'areas' or 'districts' need to be specified.")
         }
         if (is.null(links) & linkCapacity) 
             stop("When 'linkCapacity' is TRUE, argument 'links' needs to be specified.")
         if (is.null(clusters) & (thermalAvailabilities | thermalModulation)) 
             stop("When 'thermalAvailabilities' or 'thermalModulation' is TRUE, argument 'clusters' needs to be specified.")
         if (thermalAvailabilities) {
             if (!opts$scenarios) {
                 stop("Cannot import thermal availabilities because Monte Carlo scenarii have not been stored in output.")
             }
             if (!file.exists(file.path(opts$simPath, "ts-generator/thermal/mc-0"))) {
                 warning("Time series of thermal availability have not been stored in output. Time series stored in input will be used, but the result may be wrong if they have changed since the simulation has been run.")
             }
         }
         if (hydroStorage) {
             if (!opts$scenarios) {
                 stop("Cannot import hydro storage because Monte Carlo scenarii have not been stored in output.")
             }
             if (!file.exists(file.path(opts$simPath, "ts-generator/hydro/mc-0"))) {
                 warning("Time series of hydro storage have not been stored in output. Time series stored in input will be used, but the result may be wrong if they have changed since the simulation has been run.")
             }
         }
         if (misc | hydroStorageMaxPower | reserve | linkCapacity) {
             warning("When misc, hydroStorageMaxPower, reserve or linkCapacity is not null, 'readAntares' reads input time series. Result may be wrong if these time series have changed since the simulation has been run.")
         }
         if (parallel) {
             if (!requireNamespace("foreach")) 
                 stop("Parallelized importation impossible. Please install the 'foreach' package and a parallel backend provider like 'doParallel'.")
             if (!foreach::getDoParRegistered()) 
                 stop("Parallelized importation impossible. Please register a parallel backend, for instance with function 'registerDoParallel'")
         }
         colSelect = NULL
         res <- list()
         .addOutputToRes <- function(name, ids, outputFun, select, ts = timeStep) {
             if (is.null(ids) | length(ids) == 0) 
                 return(NULL)
             if (showProgress) 
                 cat(sprintf("Importing %s\n", name))
             tmp <- suppressWarnings(llply(ids, function(x, ...) outputFun(x, ...), synthesis = synthesis, 
                 mcYears = mcYears, timeStep = ts, opts = opts, select = select, colSelect = colSelect, 
                 names = names, unselect = unselect, .progress = ifelse(showProgress, 
                     "text", "none"), .parallel = parallel, .paropts = list(.packages = "antaresRead")))
             tmp <- rbindlist(tmp)
             res[[name]] <<- tmp
             gc()
         }
         res$areas <- .importOutputForAreas(areas, timeStep, select$areas, mcYears, showProgress, 
             opts, parallel = parallel)
         res$links <- .importOutputForLinks(links, timeStep, select$links, mcYears, showProgress, 
             opts, parallel = parallel)
         res$districts <- .importOutputForDistricts(districts, timeStep, select$areas, 
             mcYears, showProgress, opts, parallel = parallel)
         if (!is.null(districts)) {
             districts <- opts$districtsDef[district %in% districts]
             areas <- union(areas, districts$area)
         }
         if (!mustRun) {
             res$clusters <- .importOutputForClusters(clusters, timeStep, NULL, mcYears, 
                 showProgress, opts, mustRun = FALSE, parallel = parallel)
         }
         else {
             clustersAugmented <- intersect(opts$areasWithClusters, union(areas, clusters))
             if (length(clustersAugmented) == 0) {
                 if (!is.null(res$areas)) {
                     res$areas$thermalPmin <- 0
                     res$areas$mustRun <- 0
                     res$areas$mustRunPartial <- 0
                     res$areas$mustRunTotal <- 0
                 }
             }
             else {
                 res$clusters <- .importOutputForClusters(clustersAugmented, timeStep, 
                     NULL, mcYears, showProgress, opts, mustRun = TRUE, parallel = parallel)
                 if (!is.null(res$areas)) {
                     tmp <- copy(res$clusters)
                     tmp[, `:=`(cluster, NULL)]
                     tmp <- tmp[, .(thermalPmin = sum(thermalPmin), mustRun = sum(mustRun), 
                       mustRunPartial = sum(mustRunPartial), mustRunTotal = sum(mustRunTotal)), 
                       keyby = c(.idCols(tmp))]
                     res$areas <- .mergeByRef(res$areas, tmp)
                     res$areas[is.na(mustRunTotal), `:=`(c("thermalPmin", "mustRun", "mustRunPartial", 
                       "mustRunTotal"), 0)]
                 }
                 if (!is.null(districts)) {
                     if (nrow(districts) > 0) {
                       tmp <- copy(res$clusters)
                       tmp <- merge(tmp, districts, by = "area", allow.cartesian = TRUE)
                       tmp[, `:=`(area, NULL)]
                       tmp[, `:=`(cluster, NULL)]
                       tmp <- tmp[, .(thermalPmin = sum(thermalPmin), mustRun = sum(mustRun), 
                         mustRunPartial = sum(mustRunPartial), mustRunTotal = sum(mustRunTotal)), 
                         keyby = c(.idCols(tmp))]
                       res$districts <- .mergeByRef(res$districts, tmp)
                       res$districts[is.na(mustRunTotal), `:=`(c("thermalPmin", "mustRun", 
                         "mustRunPartial", "mustRunTotal"), 0)]
                     }
                 }
                 if (is.null(clusters)) {
                     res$clusters <- NULL
                 }
                 else if (length(clustersAugmented) > length(clusters)) {
                     res$clusters <- res$clusters[area %in% clusters]
                 }
             }
         }
         if (misc) {
             .addOutputToRes("misc", areas, .importMisc)
             if (!is.null(res$areas)) 
                 .mergeByRef(res$areas, res$misc)
             if (!is.null(districts)) {
                 if (nrow(districts) > 0) {
                     res$misc <- merge(res$misc, districts, by = "area", allow.cartesian = TRUE)
                     res$misc[, `:=`(area, NULL)]
                     res$misc <- res$misc[, lapply(.SD, sum), by = .(district, timeId)]
                     .mergeByRef(res$districts, res$misc)
                 }
             }
             res$misc <- NULL
         }
         if (thermalAvailabilities) {
             .addOutputToRes("thermalAvailabilities", clusters, .importThermal, NA)
             .mergeByRef(res$clusters, res$thermalAvailabilities)
             res$thermalAvailabilities <- NULL
         }
         if (hydroStorage) {
             .addOutputToRes("hydroStorage", areas, .importHydroStorage, NA)
             if (!is.null(res$areas)) 
                 .mergeByRef(res$areas, res$hydroStorage)
             if (!is.null(districts)) {
                 if (nrow(districts) > 0) {
                     res$hydroStorage <- merge(res$hydroStorage, districts, by = "area", 
                       allow.cartesian = TRUE)
                     res$hydroStorage[, `:=`(area, NULL)]
                     res$hydroStorage <- res$hydroStorage[, lapply(.SD, sum), by = c(.idCols(res$hydroStorage))]
                     .mergeByRef(res$districts, res$hydroStorage)
                 }
             }
             res$hydroStorage <- NULL
         }
         if (hydroStorageMaxPower) {
             .addOutputToRes("hydroStorageMaxPower", areas, .importHydroStorageMaxPower, 
                 NA)
             if (!is.null(res$areas)) 
                 .mergeByRef(res$areas, res$hydroStorageMaxPower)
             if (!is.null(res$districts)) {
                 if (nrow(districts) > 0) {
                     res$hydroStorageMaxPower <- merge(res$hydroStorageMaxPower, districts, 
                       by = "area", allow.cartesian = TRUE)
                     res$hydroStorageMaxPower[, `:=`(area, NULL)]
                     res$hydroStorageMaxPower <- res$hydroStorageMaxPower[, lapply(.SD, 
                       sum), by = .(district, timeId)]
                     .mergeByRef(res$districts, res$hydroStorageMaxPower)
                 }
             }
             res$hydroStorageMaxPower <- NULL
         }
         if (reserve) {
             .addOutputToRes("reserve", areas, .importReserves, NA)
             if (!is.null(res$areas)) 
                 .mergeByRef(res$areas, res$reserve)
             if (!is.null(districts)) {
                 if (nrow(districts) > 0) {
                     res$reserve <- merge(res$reserve, districts, by = "area", allow.cartesian = TRUE)
                     res$reserve[, `:=`(area, NULL)]
                     res$reserve <- res$reserve[, lapply(.SD, sum), by = .(district, timeId)]
                     .mergeByRef(res$districts, res$reserve)
                 }
             }
             res$reserve <- NULL
         }
         if (linkCapacity) {
             .addOutputToRes("linkCapacity", links, .importLinkCapacity, NA)
             res$links <- merge(res$links, res$linkCapacity, by = c("link", "timeId"))
             res$linkCapacity <- NULL
         }
         if (thermalModulation) {
             .addOutputToRes("thermalModulation", union(areas, clusters), .importThermalModulation, 
                 NA)
             if (!is.null(res$clusters)) {
                 .mergeByRef(res$clusters, res$thermalModulation)
             }
             res$thermalModulation <- NULL
         }
         for (i in 1:length(unselect)) {
             oldw <- getOption("warn")
             options(warn = -1)
             if ("antaresDataList" %in% class(res)) {
                 for (j in 1:length(res)) {
                     if (!is.null(res[[j]][[names(unselect)[i]]]) & length(unselect[[i]]) > 
                       0) {
                       res[[j]][[names(unselect)[i]]][, `:=`(c(unselect[[i]]), NULL)]
                     }
                 }
             }
             else {
                 if (!is.null(res[[names(unselect)[i]]]) & length(unselect[[i]]) > 0) {
                     res[[names(unselect)[i]]][, `:=`(c(unselect[[i]]), NULL)]
                 }
             }
             options(warn = oldw)
         }
         res <- .addClassAndAttributes(res, synthesis, timeStep, opts, simplify)
         addDateTimeColumns(res)
         res
     })(select = c("nostat", "-NUCLEAR"), timeStep = "hourly", showProgress = FALSE)
  5: addDateTimeColumns(res)
  6: data.table(time = timestamp, day = lubridate::day(timestamp), month = as.factor(toupper(lubridate::month(timestamp, 
         TRUE, TRUE, locale = "C"))), hour = as.factor(format(timestamp, format = "%H:%M")))
  7: as.factor(toupper(lubridate::month(timestamp, TRUE, TRUE, locale = "C")))
  8: is.factor(x)
  9: toupper(lubridate::month(timestamp, TRUE, TRUE, locale = "C"))
  10: lubridate::month(timestamp, TRUE, TRUE, locale = "C")
  11: month.default(timestamp, TRUE, TRUE, locale = "C")
  12: month(as.POSIXlt(x, tz = tz(x))$mon + 1, label, abbr, locale = locale)
  
  Error: memory exhausted (limit reached?)
  Error: memory exhausted (limit reached?)
  Error: memory exhausted (limit reached?)
  Error: memory exhausted (limit reached?)
  Error: memory exhausted (limit reached?)
  Error: memory exhausted (limit reached?)
  Execution halted