Skip to content

Commit

Permalink
Merge main onto utest
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-phelps committed Apr 16, 2024
2 parents fccf4fb + 94b2b8e commit ea43f66
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: chef
Title: Framework for generating statistical evidence
Version: 0.0.1.9001
Version: 0.1.0
Authors@R: c(
person("MEWP (Matthew David Phelps)", , , "mewp@novonordisk.com", role = "aut"),
person("NOSJ (Nicolai Skov Johnsen)", , , "nosj@novonordisk.com", role = "aut"),
Expand Down
32 changes: 15 additions & 17 deletions tests/testthat/_snaps/targets.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
# Base case: targets pipeline works

Code
ep_stat$stat_result_value
Output
[1] 45.0000000 46.0000000 26.0000000 19.0000000 18.0000000 28.0000000
[7] 5.0000000 4.0000000 4.0000000 1.0000000 3.0000000 1.0000000
[13] 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 1.0000000
[19] 1.0000000 8.0000000 9.0000000 1.0000000 1.0000000 0.0000000
[25] NA NA NA 0.2988316 0.7781907 2.8523901
[31] 0.9117548 0.2753674 4.2408159 0.3449651 NaN NaN
{
"type": "double",
"attributes": {},
"value": [45, 46, 26, 19, 18, 28, 5, 4, 4, 1, 3, 1, 0, 1, 0, 0, 0, 1, 1, 8, 9, 1, 1, 0, "NA", "NA", "NA", 0.29883164, 0.7781907, 2.85239008, 0.91175484, 0.2753674, 4.2408159, 0.34496514, "NaN", "NaN"]
}

# targets pipeline works no criteria fn and missing by_* functions

Code
ep_stat$stat_result_value
Output
[1] 45 46 26 19 18 28 5 4 4 1 3 1 0 1 0 0 0 1
{
"type": "integer",
"attributes": {},
"value": [45, 46, 26, 19, 18, 28, 5, 4, 4, 1, 3, 1, 0, 1, 0, 0, 0, 1]
}

# branching after prepare for stats step works

Code
ep_stat$stat_result_value
Output
[1] 86 86 72 72 53 53 33 33 35 35 37 37
{
"type": "integer",
"attributes": {},
"value": [86, 86, 72, 72, 53, 53, 33, 33, 35, 35, 37, 37]
}

29 changes: 19 additions & 10 deletions tests/testthat/test-targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ test_that("Base case: targets pipeline works", {
tar_load(ep_stat)
expect_equal(NROW(ep_stat), 36)
expect_equal(NCOL(ep_stat), 37)
expect_snapshot(ep_stat$stat_result_value)
expect_snapshot_value(ep_stat$stat_result_value,
tolerance = 1e-8,
style = "json2")

})

test_that("targets pipeline works no criteria fn and missing by_* functions",
Expand Down Expand Up @@ -108,14 +111,17 @@ test_that("targets pipeline works no criteria fn and missing by_* functions",
# ACT ---------------------------------------------------------------------
tar_make()

# EXPECT ------------------------------------------------------------------
x <- tar_meta() %>% as.data.table()
expect_true(all(is.na(x$error)))
tar_load(ep_stat)
expect_equal(NROW(ep_stat), 18)
expect_equal(NCOL(ep_stat), 37)
expect_snapshot(ep_stat$stat_result_value)
})
# EXPECT ------------------------------------------------------------------
x <- tar_meta() %>% as.data.table()
expect_true(all(is.na(x$error)))
tar_load(ep_stat)
expect_equal(NROW(ep_stat), 18)
expect_equal(NCOL(ep_stat), 37)
expect_snapshot_value(ep_stat$stat_result_value,
tolerance = 1e-8,
style = "json2")

})

test_that("branching after prepare for stats step works", {
# SETUP -------------------------------------------------------------------
Expand Down Expand Up @@ -161,7 +167,10 @@ test_that("branching after prepare for stats step works", {
tar_load(ep_stat)
expect_equal(NROW(ep_stat), 12)
expect_equal(NCOL(ep_stat), 37)
expect_snapshot(ep_stat$stat_result_value)
expect_snapshot_value(ep_stat$stat_result_value,
tolerance = 1e-8,
style = "json2")

})

test_that("ep_fn_map is always outdated", {
Expand Down

0 comments on commit ea43f66

Please sign in to comment.