diff --git a/DESCRIPTION b/DESCRIPTION index 02583a1..9b792b9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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"), diff --git a/tests/testthat/_snaps/targets.md b/tests/testthat/_snaps/targets.md index d008a6f..d311f95 100644 --- a/tests/testthat/_snaps/targets.md +++ b/tests/testthat/_snaps/targets.md @@ -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] + } diff --git a/tests/testthat/test-targets.R b/tests/testthat/test-targets.R index 4ba0ff3..970f2ae 100644 --- a/tests/testthat/test-targets.R +++ b/tests/testthat/test-targets.R @@ -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", @@ -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 ------------------------------------------------------------------- @@ -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", {