Skip to content

Commit

Permalink
Updates for standardising the $fit slot of a censored/glmnet model (#…
Browse files Browse the repository at this point in the history
…149)

* update tests for new `$fit` slot

* point GHA to relevant branch

* PR has been merged
  • Loading branch information
hfrick authored Nov 30, 2023
1 parent 5ff4093 commit 541cb60
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/censored-case-weights.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# proportional_hazards - glmnet censored case weights

Code
wt_fit$fit$fit$call
wt_fit$fit$call
Output
glmnet::glmnet(x = data_obj$x, y = data_obj$y, family = "cox",
weights = weights, alpha = alpha, lambda = lambda)
Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-censored-case-weights.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ test_that('proportional_hazards - glmnet censored case weights', {
set_mode("censored regression") %>%
fit(Surv(time, event) ~ ., data = dat$full)

expect_snapshot(wt_fit$fit$fit$call)
expect_unequal(coef(unwt_fit$fit$fit), coef(wt_fit$fit$fit))
skip_if_not_installed("censored", minimum_version = "0.2.0.9001")
expect_snapshot(wt_fit$fit$call)
expect_unequal(coef(unwt_fit$fit), coef(wt_fit$fit))
})
9 changes: 6 additions & 3 deletions tests/testthat/test-survival-workflows.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ test_that("can `fit()` a censored workflow with a formula", {

expect_s3_class(wf_fit$fit$fit, "model_fit")

skip_if_not_installed("censored", minimum_version = "0.2.0.9001")
expect_equal(
wf_fit$fit$fit$fit$fit$beta,
wf_fit$fit$fit$fit$beta,
censored::coxnet_train(surv ~ ., data = lung)$fit$beta
)
})
Expand Down Expand Up @@ -66,8 +67,9 @@ test_that("can `fit()` a censored workflow with variables", {

expect_s3_class(wf_fit$fit$fit, "model_fit")

skip_if_not_installed("censored", minimum_version = "0.2.0.9001")
expect_equal(
wf_fit$fit$fit$fit$fit$beta,
wf_fit$fit$fit$fit$beta,
censored::coxnet_train(surv ~ ., data = lung)$fit$beta
)
})
Expand All @@ -89,8 +91,9 @@ test_that("can `fit()` a censored workflow with a recipe", {

expect_s3_class(wf_fit$fit$fit, "model_fit")

skip_if_not_installed("censored", minimum_version = "0.2.0.9001")
expect_equal(
wf_fit$fit$fit$fit$fit$beta,
wf_fit$fit$fit$fit$beta,
censored::coxnet_train(surv ~ ., data = lung)$fit$beta
)
})
Expand Down

0 comments on commit 541cb60

Please sign in to comment.