|
| 1 | +test_that("flow function arg errors and warnings are appropriate", { |
| 2 | + expect_error( |
| 3 | + mp_per_capita_flow(from = "S", to = "I", rate = "beta * I") |
| 4 | + , "flow_name must be specified when rate is a one_sided formula or character string" |
| 5 | + ) |
| 6 | + expect_error( |
| 7 | + mp_inflow(to = "I", rate = "beta") |
| 8 | + , "flow_name must be specified when rate is a one_sided formula or character string" |
| 9 | + ) |
| 10 | + expect_error( |
| 11 | + mp_outflow(from = "S", rate = "beta") |
| 12 | + , "flow_name must be specified when rate is a one_sided formula or character string" |
| 13 | + ) |
| 14 | + expect_error( |
| 15 | + mp_per_capita_inflow(from = "N", to = "S", rate = "mu") |
| 16 | + , "flow_name must be specified when rate is a one_sided formula or character string" |
| 17 | + ) |
| 18 | + expect_error( |
| 19 | + mp_per_capita_outflow(from = "S", rate = "beta") |
| 20 | + , "flow_name must be specified when rate is a one_sided formula or character string" |
| 21 | + ) |
| 22 | + expect_warning( |
| 23 | + mp_per_capita_flow(from = "S", to = "I", rate = "beta * I", abs_rate = "infection") |
| 24 | + , "The abs_rate argument is deprecated; please use 'flow_name' instead" |
| 25 | + ) |
| 26 | + expect_warning( |
| 27 | + mp_inflow(to = "I", rate = "beta", abs_rate = "infection") |
| 28 | + , "The abs_rate argument is deprecated; please use 'flow_name' instead" |
| 29 | + ) |
| 30 | + expect_warning( |
| 31 | + mp_inflow(to = "I", rate = "beta", abs_rate = "infection") |
| 32 | + , "The abs_rate argument is deprecated; please use 'flow_name' instead" |
| 33 | + ) |
| 34 | + expect_warning( |
| 35 | + mp_per_capita_inflow(from = "N", to = "S", rate = "mu", abs_rate = "birth") |
| 36 | + , "The abs_rate argument is deprecated; please use 'flow_name' instead" |
| 37 | + ) |
| 38 | + expect_warning( |
| 39 | + mp_per_capita_outflow(from = "S", rate = "beta", abs_rate = "death") |
| 40 | + , "The abs_rate argument is deprecated; please use 'flow_name' instead" |
| 41 | + ) |
| 42 | +}) |
| 43 | + |
| 44 | +test_that("empty specs give empty information", { |
| 45 | + expect_identical(nrow(mp_flow_frame(mp_tmb_model_spec())), 0L) |
| 46 | + expect_identical(mp_state_vars(mp_tmb_model_spec()), character()) |
| 47 | +}) |
| 48 | + |
| 49 | +test_that("warnings given if formulas are between flows", { |
| 50 | + expect_warning({ |
| 51 | + mp_tmb_model_spec( |
| 52 | + during = list( |
| 53 | + mp_per_capita_flow("S", "I", "beta * I / N", "infection") |
| 54 | + , N ~ S + I |
| 55 | + , mp_per_capita_flow("I", "R", "gamma", "recovery") |
| 56 | + ) |
| 57 | + ) |
| 58 | + } |
| 59 | + , "Raw formula-valued expressions were inserted between flow-based expressions" |
| 60 | + ) |
| 61 | +}) |
| 62 | + |
| 63 | +test_that("find all paths works with non-dag", { |
| 64 | + shiver = test_cache_read("SPEC-shiver.rds") |
| 65 | + expect_setequal( |
| 66 | + shiver |> mp_flow_frame(loops = "^vacc") |> find_all_paths("S") |
| 67 | + , list( |
| 68 | + c("S", "E", "I", "H", "R") |
| 69 | + , c("S", "E", "I", "R") |
| 70 | + , c("S", "V", "E", "I", "H", "R") |
| 71 | + , c("S", "V", "E", "I", "R") |
| 72 | + ) |
| 73 | + ) |
| 74 | +}) |
0 commit comments