Skip to content

Commit

Permalink
Completed testing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fontikar committed Mar 24, 2024
1 parent 797316c commit 4536570
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Binary file not shown.
16 changes: 16 additions & 0 deletions tests/testthat/fixtures/linear/make_lm.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Make some data
lm_data <- data.frame(X = Loblolly$age,
Y = Loblolly$height,
N = nrow(Loblolly))

saveRDS(lm_data, file = "lm_data.rds")

# Run a baseline model for the data
set.seed(2024)
suppressWarnings( #Suppresses stan warnings
lm_baseline <- rmot_model("linear") |>
rmot_assign_data(X = lm_data$X,
Y = lm_data$Y,
N = nrow(lm_data)) |>
rmot_run(chains = 1, iter = 300, verbose = FALSE, show_messages = FALSE)
)

# Save output to compare as
lm_baseline_output <- rstan::summary(lm_baseline)$summary

saveRDS(lm_baseline_output, "lm_baseline_output.rds")
13 changes: 4 additions & 9 deletions tests/testthat/test-rmot_models.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@



test_that("Model structures", {
expect_named(rmot_model("linear"))
expect_type(rmot_model("linear"), "list")
Expand All @@ -19,9 +16,7 @@ test_that("Model structures", {

test_that("Execution and output: Linear", {
lm_data <- readRDS(test_path("fixtures", "linear", "lm_data.rds"))

print(rlang::caller_env())
print(globalenv())
lm_baseline_output <- readRDS(test_path("fixtures", "linear", "lm_baseline_output.rds"))

# Test linear model
set.seed(2024)
Expand All @@ -33,9 +28,9 @@ test_that("Execution and output: Linear", {
rmot_run(chains = 1, iter = 300, verbose = FALSE, show_messages = FALSE)
)


expect_visible(lm_test)
# expect_s4_class(lm_test, "stanfit")
expect_equal(rstan::summary(lm_test)$summary, lm_baseline_output)
expect_visible(lm_test)
expect_s4_class(lm_test, "stanfit")
})

# test_that("Execution: Constant single individual", {
Expand Down

0 comments on commit 4536570

Please sign in to comment.