We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Caching does not work properly with DGPs (and Methods) that take in function arguments that explicitly contain a nested function.
Example:
rm(list = ls()) library(simChef) library(magrittr) n <- 300 p <- 3 dgp_fun <- function(n, p, func_arg) { X <- matrix(rnorm(n * p), nrow = n, ncol = p) y <- rnorm(n) return(list(X = X, y = y)) } method_fun <- function(X, y) { lm_df <- cbind(data.frame(X), .y = y) lm_fit <- lm(.y ~ ., dat = lm_df) return(coef(lm_fit)) } method <- create_method(method_fun, .name = "Method")
Example DGPs where caching works:
helper_fun <- function(x) sum(x) working_func_arg <- function() { z <- apply(X, 1, FUN = helper_fun) } working_dgp <- create_dgp(dgp_fun, .name = "Working DGP", n = n, p = p, func_arg = working_func_arg) experiment <- create_experiment() %>% add_dgp(working_dgp) %>% add_method(method) out <- run_experiment(experiment, save = TRUE, use_cached = FALSE) out <- run_experiment(experiment, save = TRUE, use_cached = TRUE)
Example DGPs where caching does not work:
buggy_func_arg1 <- function() { z <- apply(X, 1, FUN = function(x) sum(x)) } buggy_dgp1 <- create_dgp(dgp_fun, .name = "Buggy DGP1", n = n, p = p, func_arg = buggy_func_arg1) buggy_func_arg2 <- function() { function(x) sum(x) return("hi") } buggy_dgp2 <- create_dgp(dgp_fun, .name = "Buggy DGP2", n = n, p = p, func_arg = buggy_func_arg2) experiment <- create_experiment() %>% add_dgp(buggy_dgp1) %>% add_dgp(buggy_dgp2) %>% add_method(method) out <- run_experiment(experiment, save = TRUE, use_cached = FALSE) out <- run_experiment(experiment, save = TRUE, use_cached = TRUE)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Caching does not work properly with DGPs (and Methods) that take in function arguments that explicitly contain a nested function.
Example:
Example DGPs where caching works:
Example DGPs where caching does not work:
The text was updated successfully, but these errors were encountered: