Skip to content

Commit 2bdcf56

Browse files
committed
Updated JSON file output docs to ensure they write to a temp file which is later unlinked
1 parent 6a2d229 commit 2bdcf56

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

R/bcf.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,9 @@ saveBCFModelToJson <- function(object){
18891889
#' num_gfr = 10, num_burnin = 0, num_mcmc = 10,
18901890
#' prognostic_forest_params = mu_params,
18911891
#' treatment_effect_forest_params = tau_params)
1892-
#' saveBCFModelToJsonFile(bcf_model, "test.json")
1892+
#' tmpjson <- tempfile(fileext = ".json")
1893+
#' saveBCFModelToJsonFile(bcf_model, file.path(tmpjson))
1894+
#' unlink(tmpjson)
18931895
saveBCFModelToJsonFile <- function(object, filename){
18941896
# Convert to Json
18951897
jsonobj <- saveBCFModelToJson(object)
@@ -2218,8 +2220,10 @@ createBCFModelFromJson <- function(json_object){
22182220
#' num_gfr = 10, num_burnin = 0, num_mcmc = 10,
22192221
#' prognostic_forest_params = mu_params,
22202222
#' treatment_effect_forest_params = tau_params)
2221-
#' saveBCFModelToJsonFile(bcf_model, "test.json")
2222-
#' bcf_model_roundtrip <- createBCFModelFromJsonFile("test.json")
2223+
#' tmpjson <- tempfile(fileext = ".json")
2224+
#' saveBCFModelToJsonFile(bcf_model, file.path(tmpjson))
2225+
#' bcf_model_roundtrip <- createBCFModelFromJsonFile(file.path(tmpjson))
2226+
#' unlink(tmpjson)
22232227
createBCFModelFromJsonFile <- function(json_filename){
22242228
# Load a `CppJson` object from file
22252229
bcf_json <- createCppJsonFile(json_filename)

man/createBCFModelFromJsonFile.Rd

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/saveBCFModelToJsonFile.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)