From d58bc9a135b0f5a6dd906cb34047ff518c4f9e9c Mon Sep 17 00:00:00 2001 From: Gregor Gorjanc Date: Wed, 11 Feb 2026 22:17:14 +0000 Subject: [PATCH] Delete temp files Fixes #77 --- RcppTskit/R/Class-TableCollection.R | 1 + RcppTskit/R/Class-TreeSequence.R | 1 + RcppTskit/man/TableCollection.Rd | 2 ++ RcppTskit/man/TreeSequence.Rd | 2 ++ RcppTskit/src/RcppTskit.cpp | 2 ++ RcppTskit/tests/testthat/test_load_summary_and_dump.R | 4 ++++ RcppTskit/vignettes/RcppTskit_intro.qmd | 1 + 7 files changed, 13 insertions(+) diff --git a/RcppTskit/R/Class-TableCollection.R b/RcppTskit/R/Class-TableCollection.R index bdd9636..216c44b 100644 --- a/RcppTskit/R/Class-TableCollection.R +++ b/RcppTskit/R/Class-TableCollection.R @@ -65,6 +65,7 @@ TableCollection <- R6Class( #' dump_file <- tempfile() #' tc$dump(dump_file) #' tc$write(dump_file) # alias + #' \dontshow{file.remove(dump_file)} dump = function(file) { tc_ptr_dump(self$pointer, file = file, options = 0L) }, diff --git a/RcppTskit/R/Class-TreeSequence.R b/RcppTskit/R/Class-TreeSequence.R index e8d8ae0..066530e 100644 --- a/RcppTskit/R/Class-TreeSequence.R +++ b/RcppTskit/R/Class-TreeSequence.R @@ -71,6 +71,7 @@ TreeSequence <- R6Class( #' dump_file <- tempfile() #' ts$dump(dump_file) #' ts$write(dump_file) # alias + #' \dontshow{file.remove(dump_file)} dump = function(file) { ts_ptr_dump(self$pointer, file = file, options = 0L) }, diff --git a/RcppTskit/man/TableCollection.Rd b/RcppTskit/man/TableCollection.Rd index 38b2593..067c0f9 100644 --- a/RcppTskit/man/TableCollection.Rd +++ b/RcppTskit/man/TableCollection.Rd @@ -29,6 +29,7 @@ tc <- TableCollection$new(file = ts_file) dump_file <- tempfile() tc$dump(dump_file) tc$write(dump_file) # alias +\dontshow{file.remove(dump_file)} ## ------------------------------------------------ ## Method `TableCollection$tree_sequence` @@ -171,6 +172,7 @@ tc <- TableCollection$new(file = ts_file) dump_file <- tempfile() tc$dump(dump_file) tc$write(dump_file) # alias +\dontshow{file.remove(dump_file)} } \if{html}{\out{}} diff --git a/RcppTskit/man/TreeSequence.Rd b/RcppTskit/man/TreeSequence.Rd index 4c00aaf..b89fba3 100644 --- a/RcppTskit/man/TreeSequence.Rd +++ b/RcppTskit/man/TreeSequence.Rd @@ -33,6 +33,7 @@ ts <- ts_load(ts_file) dump_file <- tempfile() ts$dump(dump_file) ts$write(dump_file) # alias +\dontshow{file.remove(dump_file)} ## ------------------------------------------------ ## Method `TreeSequence$dump_tables` @@ -318,6 +319,7 @@ ts <- ts_load(ts_file) dump_file <- tempfile() ts$dump(dump_file) ts$write(dump_file) # alias +\dontshow{file.remove(dump_file)} } \if{html}{\out{}} diff --git a/RcppTskit/src/RcppTskit.cpp b/RcppTskit/src/RcppTskit.cpp index 05298ad..36d26b0 100644 --- a/RcppTskit/src/RcppTskit.cpp +++ b/RcppTskit/src/RcppTskit.cpp @@ -225,6 +225,7 @@ SEXP tc_ptr_load(const std::string file, const int options = 0) { // ts_ptr <- RcppTskit:::ts_ptr_load(ts_file) // dump_file <- tempfile() // RcppTskit:::ts_ptr_dump(ts_ptr, dump_file) +// file.remove(dump_file) // [[Rcpp::export]] void ts_ptr_dump(const SEXP ts, const std::string file, const int options = 0) { const tsk_flags_t dump_options = @@ -250,6 +251,7 @@ void ts_ptr_dump(const SEXP ts, const std::string file, const int options = 0) { // tc_ptr <- RcppTskit:::tc_ptr_load(ts_file) // dump_file <- tempfile() // RcppTskit:::tc_ptr_dump(tc_ptr, dump_file) +// file.remove(dump_file) // [[Rcpp::export]] void tc_ptr_dump(const SEXP tc, const std::string file, const int options = 0) { const tsk_flags_t dump_options = diff --git a/RcppTskit/tests/testthat/test_load_summary_and_dump.R b/RcppTskit/tests/testthat/test_load_summary_and_dump.R index 6881186..5b1281f 100644 --- a/RcppTskit/tests/testthat/test_load_summary_and_dump.R +++ b/RcppTskit/tests/testthat/test_load_summary_and_dump.R @@ -390,6 +390,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { ts_ptr_dump(ts_ptr, dump_file) rm(ts_ptr) ts_ptr <- ts_ptr_load(dump_file) + file.remove(dump_file) # Simple comparison of summaries n <- ts_ptr_summary(ts_ptr) @@ -438,6 +439,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { rm(tc_ptr) tc_ptr <- tc_ptr_load(dump_file) ts_ptr <- ts_ptr_load(dump_file) + file.remove(dump_file) # Simple comparison of summaries n_ts <- ts_ptr_summary(ts_ptr) @@ -474,6 +476,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { ts$dump(dump_file) rm(ts) ts <- ts_load(dump_file) + file.remove(dump_file) # Simple comparison of summaries n_ptr <- ts_ptr_summary(ts$pointer) @@ -515,6 +518,7 @@ test_that("ts/tc_load(), ts/tc_summary*(), and ts/tc_dump(x) work", { tc$dump(dump_file) rm(tc) tc <- tc_load(dump_file) + file.remove(dump_file) # Simple comparison of summaries n_ptr <- tc_ptr_summary(tc$pointer) diff --git a/RcppTskit/vignettes/RcppTskit_intro.qmd b/RcppTskit/vignettes/RcppTskit_intro.qmd index 8efc419..8656036 100644 --- a/RcppTskit/vignettes/RcppTskit_intro.qmd +++ b/RcppTskit/vignettes/RcppTskit_intro.qmd @@ -276,6 +276,7 @@ ts$dump(file = ts_file) # ... and to bring it back to R, use ... ts2 <- ts_load(ts_file) ts$num_individuals() # 2 (if you have run the above Python code) +file.remove(ts_file) # You can work similarly with table collection between R & Python tc <- ts$dump_tables()