1 context("computeFilaments")
3 test_that("output is as expected on simulated series",
5 data = getDataTest(150)
14 # index 144-1 == 143 : serie type 2
15 pred = computeForecast(data, 143, "Neighbors", "Zero", predict_from=8,
16 horizon=length(data$getSerie(1)), simtype="endo", local=FALSE, h_window=1)
17 f = computeFilaments(data, pred, 1, 8, limit=60, plot=FALSE)
19 # Expected output: 50-3-10 series of type 2, then 23 series of type 3 (closest next)
20 expect_identical(length(f$neighb_indices), as.integer(60))
21 expect_identical(length(f$colors), as.integer(60))
22 expect_equal(f$index, 143)
23 expect_true(all(I(f$neighb_indices) >= 2))
26 expect_equal(I(f$neighb_indices[i]), 2)
27 expect_match(f$colors[i], f$colors[1])
31 expect_equal(I(f$neighb_indices[i]), 3)
32 expect_match(f$colors[i], f$colors[38])
34 expect_match(f$colors[1], "#1*")
35 expect_match(f$colors[38], "#E*")
37 # index 143-1 == 142 : serie type 1
38 pred = computeForecast(data, 143, "Neighbors", "Zero", predict_from=8,
39 horizon=length(data$getSerie(1)), simtype="endo", local=FALSE, h_window=1)
40 f = computeFilaments(data, pred, 1, 8, limit=50, plot=FALSE)
42 # Expected output: 50-10-3 series of type 1, then 13 series of type 3 (closest next)
43 # NOTE: -10 because only past days with no-NAs tomorrow => exclude type 1 in [60,90[
44 expect_identical(length(f$neighb_indices), as.integer(50))
45 expect_identical(length(f$colors), as.integer(50))
46 expect_equal(f$index, 143)
47 expect_true(all(I(f$neighb_indices) != 2))
50 expect_equal(I(f$neighb_indices[i]), 1)
51 expect_match(f$colors[i], f$colors[1])
55 expect_equal(I(f$neighb_indices[i]), 3)
56 expect_match(f$colors[i], f$colors[38])
58 expect_match(f$colors[1], "#1*")
59 expect_match(f$colors[38], "#E*")