X-Git-Url: https://git.auder.net/?p=talweg.git;a=blobdiff_plain;f=pkg%2Ftests%2Ftestthat%2Ftest-similarDays.R;h=05a7b0eef2239194ad37b08ef59f619c4aedd502;hp=0d33fcef7162e445f73ee6ac25034d9c6626e7d5;hb=c36568faefc97bb417d355e2084398c1ad1acf92;hpb=3ddf1c12af0c167fe7d3bb59e63258550270cfc5 diff --git a/pkg/tests/testthat/test-similarDays.R b/pkg/tests/testthat/test-similarDays.R index 0d33fce..05a7b0e 100644 --- a/pkg/tests/testthat/test-similarDays.R +++ b/pkg/tests/testthat/test-similarDays.R @@ -1,16 +1,27 @@ context("Get similar days") -itestthat("getSimilarDaysIndices works as expected", +test_that("getSimilarDaysIndices works as expected", { - getSimilarDaysIndices(index, data, limit, same_season, days_in=NULL) - #... + data = getDataTest(150) + + # Index 142 is a tuesday (142 = 2 mod 7) + N142_1 = getSimilarDaysIndices(142, data, limit=7, same_season=FALSE, days_in=NULL) + expect_equal(N142_1, c(141,137,136,135,134,130,129)) + # Index 139 = saturday + N139_1 = getSimilarDaysIndices(139, data, limit=7, same_season=FALSE, days_in=NULL) + expect_equal(N139_1, c(132,125,118,111,104,97,90)) + + # With 'days_in' constraint + N142_2 = getSimilarDaysIndices(142, data, limit=7, same_season=FALSE, days_in=2*(1:75)) + expect_equal(N142_2, c(136,134,130,128,122,120,116)) + N139_2 = getSimilarDaysIndices(139, data, limit=7, same_season=FALSE, days_in=2*(1:75)) + expect_equal(N139_2, c(132,118,104,90,76,62,48)) }) -{ - index = dateIndexToInteger(index, data) -testthat("getConstrainedNeighbs works as expected", +test_that("getConstrainedNeighbs works as expected", { - .getConstrainedNeighbs(today, data, fdays, min_neighbs=10, max_neighbs=12) - #... +# data = getDataTest(150) +# N142_1 = .getConstrainedNeighbs(142, data, fdays, min_neighbs=7, max_neighbs=7) +# #...maybe we need an easier test data })