Problem in `is_valid_rij_list()`
Opened this issue · 2 comments
jacobbien commented
Here is a minimal example from @gregfaletto showing the problem:
library(simulator)
set.seed(12375)
simulate_func <- function(x, nsim){
ret_list <- list()
for(i in 1:nsim){
ret_list[[i]] <- 1
}
return(ret_list)
}
error_sim_model <- function(x){
my_model <- new_model(name = "error_sim_model",
label = "err_model",
params = list(x=x),
simulate = simulate_func
)
return(my_model)
}
bad_meth <- new_method("bad_meth", "Bad method",
method = function(model, draw) {
if(as.logical(rbinom(n=1, size=1, prob=0.5))){
return(list(a=2))
} else{
return(list(b=3))
}
return(ret)
}
)
sim <- new_simulation("sim", "Error sim")
sim <- generate_model(sim, error_sim_model, x=2)
sim <- simulate_from_model(sim, nsim = 20)
sim <- run_method(sim, list(bad_meth))
jacobbien commented
The problem is that the above example was giving the following error:
Error in is_valid_rij_list(object@out, object@index) :
object 'errors' not found
After the fix, it still gives an error, but now it's one that points the user to a problem in the above code:
Error in validObject(.Object) :
invalid class “Output” object: all out$ri.j must have same elements.