diff --git a/R/bcf.R b/R/bcf.R index 3ef5faca..60821e79 100644 --- a/R/bcf.R +++ b/R/bcf.R @@ -1889,7 +1889,9 @@ saveBCFModelToJson <- function(object){ #' num_gfr = 10, num_burnin = 0, num_mcmc = 10, #' prognostic_forest_params = mu_params, #' treatment_effect_forest_params = tau_params) -#' saveBCFModelToJsonFile(bcf_model, "test.json") +#' tmpjson <- tempfile(fileext = ".json") +#' saveBCFModelToJsonFile(bcf_model, file.path(tmpjson)) +#' unlink(tmpjson) saveBCFModelToJsonFile <- function(object, filename){ # Convert to Json jsonobj <- saveBCFModelToJson(object) @@ -2218,8 +2220,10 @@ createBCFModelFromJson <- function(json_object){ #' num_gfr = 10, num_burnin = 0, num_mcmc = 10, #' prognostic_forest_params = mu_params, #' treatment_effect_forest_params = tau_params) -#' saveBCFModelToJsonFile(bcf_model, "test.json") -#' bcf_model_roundtrip <- createBCFModelFromJsonFile("test.json") +#' tmpjson <- tempfile(fileext = ".json") +#' saveBCFModelToJsonFile(bcf_model, file.path(tmpjson)) +#' bcf_model_roundtrip <- createBCFModelFromJsonFile(file.path(tmpjson)) +#' unlink(tmpjson) createBCFModelFromJsonFile <- function(json_filename){ # Load a `CppJson` object from file bcf_json <- createCppJsonFile(json_filename) diff --git a/man/createBCFModelFromJsonFile.Rd b/man/createBCFModelFromJsonFile.Rd index 8d5a61bd..d5eb7327 100644 --- a/man/createBCFModelFromJsonFile.Rd +++ b/man/createBCFModelFromJsonFile.Rd @@ -82,6 +82,8 @@ bcf_model <- bcf(X_train = X_train, Z_train = Z_train, y_train = y_train, num_gfr = 10, num_burnin = 0, num_mcmc = 10, prognostic_forest_params = mu_params, treatment_effect_forest_params = tau_params) -saveBCFModelToJsonFile(bcf_model, "test.json") -bcf_model_roundtrip <- createBCFModelFromJsonFile("test.json") +tmpjson <- tempfile(fileext = ".json") +saveBCFModelToJsonFile(bcf_model, file.path(tmpjson)) +bcf_model_roundtrip <- createBCFModelFromJsonFile(file.path(tmpjson)) +unlink(tmpjson) } diff --git a/man/saveBCFModelToJsonFile.Rd b/man/saveBCFModelToJsonFile.Rd index 705e0655..8735a25b 100644 --- a/man/saveBCFModelToJsonFile.Rd +++ b/man/saveBCFModelToJsonFile.Rd @@ -82,5 +82,7 @@ bcf_model <- bcf(X_train = X_train, Z_train = Z_train, y_train = y_train, num_gfr = 10, num_burnin = 0, num_mcmc = 10, prognostic_forest_params = mu_params, treatment_effect_forest_params = tau_params) -saveBCFModelToJsonFile(bcf_model, "test.json") +tmpjson <- tempfile(fileext = ".json") +saveBCFModelToJsonFile(bcf_model, file.path(tmpjson)) +unlink(tmpjson) }