Skip to content

Commit

Permalink
Update some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kenkellner committed Dec 7, 2024
1 parent e5d80cd commit d8c2205
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/power.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ powerAnalysis_internal <- function(object, model, data_sims,
parallel::clusterEvalQ(cl, library(unmarked))
}

sum_dfs <- pbapply::pblapply(data_sims, function(x){
sum_dfs <- lapply2(data_sims, function(x){
fit <- fun(..., data = x)
}, cl=cl)
sum_dfs <- lapply(sum_dfs, get_summary_df, effects=effects, nulls=nulls)
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_occuMS.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ test_that("occuMS can fit the multinomial model",{

#Check bootstrapped error for predict
expect_equivalent(as.numeric(pr[[1]][1,]),
c(0.2292279,0.11235796,0.08024297,0.45486279), tol=1e-4)
c(0.2292279,0.11235796,0.08024297,0.45486279), tol=0.1)

#det
nul <- capture.output(pr <- predict(fit_C, "det"))
Expand All @@ -173,7 +173,7 @@ test_that("occuMS can fit the multinomial model",{
expect_equal(names(pr),c('p[11]','p[12]','p[22]'))

expect_equivalent(as.numeric(pr[[1]][1,]),
c(0.285455,0.07441389,0.18922129,0.48677813), tol=1e-4)
c(0.285455,0.07441389,0.18922129,0.48677813), tol=0.1)

#with new data (some missing)
newdata <- data.frame(oc1=rnorm(5),oc2=rnorm(5))
Expand All @@ -182,7 +182,7 @@ test_that("occuMS can fit the multinomial model",{
expect_true(is.na(pr[[1]][1,1]))
expect_equivalent(nrow(pr[[1]]), nrow(newdata))
expect_equivalent(as.numeric(pr[[1]][2,]),
c(0.343157,0.07801936,0.20967511,0.49916983),tol=1e-4)
c(0.343157,0.07801936,0.20967511,0.49916983),tol=0.1)

newdata <- data.frame(sc1=rnorm(5),sc2=rnorm(5))
newdata[1,1] <- NA
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test_powerAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ test_that("custom datasets can be passed to powerAnalysis",{
test_that("powerAnalysis can be run in parallel",{
skip_on_cran()
skip_on_ci()
#skip_if(!requireNamespace("pbapply", quietly=TRUE),
# "pbapply package unavailable")

set.seed(123)
ef <- list(state=c(0, -0.4), det=0)
Expand Down

0 comments on commit d8c2205

Please sign in to comment.