rte-antares-rpackage / antaresViz

ANTARES Visualizations

Home Page:https://rte-antares-rpackage.github.io/antaresViz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

:= length error with next data.table release

mattdowle opened this issue · comments

Hi,
I hope this change is ok; I sent an email on 24th Jan : Rdatatable/data.table#3310.
With data.table about to be released to CRAN, antaresViz fails with :

> test_check("antaresViz")
── 1. Error: (unknown) (@test-plotMap.R#3)  ────────────────────────────────────
Supplied 336 items to be assigned to 3024 items of column 'time'. The RHS length must either be 1 (single values are ok) or match the LHS length exactly. If you wish to 'recycle' the RHS please use rep()
 explicitly to make this intent clear to readers of your code.
1: describe("plotMap, no interactive", {
       dta <- readAntares(areas = "all", links = "all", showProgress = FALSE)
       testClass <- function(obj) {
           class(obj)[1] == "combineWidgets"
       }
       load(system.file("mapLayout/ml.rda", package = "antaresViz"))
       listArgs <- list(noarg = list(x = dta, interactive = FALSE, mapLayout = ml), 
           colorLinks = list(x = dta, interactive = FALSE, mapLayout = ml, colLinkVar = "FLOW LIN."), 
           colorAll = list(x = dta, interactive = FALSE, mapLayout = ml, colLinkVar = "FLOW LIN.", 
               colAreaVar = "OP. COST"))
       lapply(listArgs, function(X) {
           test_that(names(listArgs), {
               re1 <- do.call(plotMap, X)
               expect_true(testClass(re1))
           })
       })
   }) at testthat/test-plotMap.R:3
2: eval(substitute(code), describe_environment)
3: eval(substitute(code), describe_environment)
4: readAntares(areas = "all", links = "all", showProgress = FALSE) at testthat/test-plotMap.R:5
5: .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)
6: .loadAreas(areas = areas, fid = fid, select = select$areas, mcYears = mcYears, GP = GP, 
       mcType = mcType, synthesis = synthesis, simplify = simplify, attrib = attrib)
7: areas[, `:=`(c(names(tim)), tim)]
8: `[.data.table`(areas, , `:=`(c(names(tim)), tim))

══ testthat results  ═══════════════════════════════════════════════════════════
OK: 243 SKIPPED: 3 FAILED: 1
1. Error: (unknown) (@test-plotMap.R#3) 

Error: testthat unit tests failed
Execution halted

I've traced it through and it seems to be this line (https://github.com/rte-antares-rpackage/antaresRead/blob/9cecead59ffff5217d7b24b28fd59c7e01aa7dd0/R/h5_antaresReadH5.R#L538) in the antaresRead package. 3024 is exactly 9 times 336. Was it intentional to recycle GP here? I'm not sure whether the issue is in data being passed to readAntares in antaresViz or whether it's the line in antaresRead.

I had the intention of making a pull request but I'm not quite following what's happening. Would you be able to take a look before data.table is released?

Best, Matt

Hello Matt,
Thank you for investigating the source of the problem, it's now fixed on GitHub, we are preparing an update on CRAN for tomorrow.

Best,

Victor

Many thanks @pvictor. I see the update on CRAN and it's passing cleanly.
Best, Matt