-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved power2 via furrr #15
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,32 +56,40 @@ power2 <- function(model1 = "gnp", model2 = "k_regular", | |
if (!is.null(seed)) | ||
withr::local_seed(seed) | ||
|
||
pvalues <- replicate( | ||
R, | ||
test2_global( | ||
x = nvd( | ||
model = model1, | ||
n = n1, | ||
num_vertices = num_vertices, | ||
model_params = model1_params, | ||
seed = NULL | ||
), | ||
y = nvd( | ||
model = model2, | ||
n = n2, | ||
num_vertices = num_vertices, | ||
model_params = model2_params, | ||
seed = NULL | ||
), | ||
representation = representation, | ||
distance = distance, | ||
stats = stats, | ||
B = B, | ||
test = test, | ||
k = k, | ||
seed = 1234 | ||
)$pvalue | ||
) | ||
progressr::handlers(progressr::handler_progress(format="[:bar] :percent :eta :message")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user defines these. Not us as package developers. |
||
|
||
fun <- function(xs) { | ||
p <- progressr::progressor(steps = xs) | ||
pbfun <- function(dummy){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
p() #signal progress | ||
test2_global( | ||
x = nvd( | ||
model = model1, | ||
n = n1, | ||
num_vertices = num_vertices, | ||
model_params = model1_params, | ||
seed = NULL | ||
), | ||
y = nvd( | ||
model = model2, | ||
n = n2, | ||
num_vertices = num_vertices, | ||
model_params = model2_params, | ||
seed = NULL | ||
), | ||
representation = representation, | ||
distance = distance, | ||
stats = stats, | ||
B = B, | ||
test = test, | ||
k = k, | ||
seed = 1234 | ||
)$pvalue | ||
} | ||
y <- furrr::future_map_dbl(1:xs, pbfun, .options = furrr::furrr_options(seed = TRUE)) | ||
} | ||
|
||
progressr::with_progress(pvalues <- fun(R)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here. |
||
|
||
mean(pvalues <= alpha) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do you use the
progress
package?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented before:
I solve errors by adding the
progress
package in DESCRIPTION file, but I do not use it explicitly.