1 context("computeFilaments")
3 test_that("output is as expected on simulated series",
5 data = getDataTest(150)
7 # index 143 : serie type 2
8 pred = computeForecast(data, 143, "Neighbors", "Zero",
9 horizon=length(data$getSerie(1)), simtype="endo", local=FALSE, h_window=1)
10 f = computeFilaments(data, pred, 1, limit=60, plot=FALSE)
12 # Expected output: 50-3-10 series of type 2, then 23 series of type 3 (closest next)
13 expect_identical(length(f$neighb_indices), as.integer(60))
14 expect_identical(length(f$colors), as.integer(60))
15 expect_equal(f$index, 143)
16 expect_true(all(I(f$neighb_indices) >= 2))
19 expect_equal(I(f$neighb_indices[i]), 2)
20 expect_match(f$colors[i], f$colors[1])
24 expect_equal(I(f$neighb_indices[i]), 3)
25 expect_match(f$colors[i], f$colors[38])
27 expect_match(f$colors[1], "#1*")
28 expect_match(f$colors[38], "#E*")
30 # index 142 : serie type 1
31 pred = computeForecast(data, 142, "Neighbors", "Zero",
32 horizon=length(data$getSerie(1)), simtype="endo", local=FALSE, h_window=1)
33 f = computeFilaments(data, pred, 1, limit=50, plot=FALSE)
35 # Expected output: 50-10-3 series of type 1, then 13 series of type 3 (closest next)
36 # NOTE: -10 because only past days with no-NAs tomorrow => exclude type 1 in [60,90[
37 expect_identical(length(f$neighb_indices), as.integer(50))
38 expect_identical(length(f$colors), as.integer(50))
39 expect_equal(f$index, 142)
40 expect_true(all(I(f$neighb_indices) != 2))
43 expect_equal(I(f$neighb_indices[i]), 1)
44 expect_match(f$colors[i], f$colors[1])
48 expect_equal(I(f$neighb_indices[i]), 3)
49 expect_match(f$colors[i], f$colors[38])
51 expect_match(f$colors[1], "#1*")
52 expect_match(f$colors[38], "#E*")