Skip to content

Commit 2873227

Browse files
committed
v0.4.0 on CRAN
1 parent b515f37 commit 2873227

File tree

73 files changed

+734
-1846
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+734
-1846
lines changed

CRAN-SUBMISSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Version: 0.3.0
2-
Date: 2025-10-10 21:27:52 UTC
3-
SHA: 7df902a139baf9562afb5fdbe849f1c6f6454098
1+
Version: 0.4.0
2+
Date: 2025-12-04 13:21:04 UTC
3+
SHA: b515f37932f4f590f785e2271e4d95b97c12546b

Makefile

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@ clean:
44
@Rscript -e 'devtools::clean_dll("extended-tests/cpp4rbenchmark")'
55
@Rscript -e 'devtools::clean_dll("extended-tests/Rcppbenchmark")'
66

7-
register:
8-
@Rscript -e 'cpp4r::register("extended-tests/cpp4rtest")'
9-
@Rscript -e 'cpp4r::register("extended-tests/cpp4rbenchmark")'
10-
117
install:
128
@Rscript -e 'devtools::install("./")'
13-
@Rscript -e 'cpp4r::unvendor("./extended-tests/cpp4r4rtest/src/vendor");
14-
cpp4r::vendor("./extended-tests/cpp4r4rtest/src/vendor")'
9+
@Rscript -e 'cpp4r::unvendor("./extended-tests/cpp4rtest/src/vendor"); cpp4r::vendor("./extended-tests/cpp4rtest/src/vendor")'
1510

1611
docs:
1712
@Rscript -e 'devtools::document("./"); pkgsite::build_site("./")'
@@ -21,14 +16,12 @@ check:
2116
@echo "Checking R code"
2217
@$(MAKE) clean
2318
@$(MAKE) install
24-
@$(MAKE) register
2519
@Rscript -e 'devtools::check("./", error_on = "error")'
2620
@echo "==============================="
2721
@echo "Checking C++ code"
2822
@$(MAKE) install
2923
@rm -f extended-tests-results/*.log
3024
@rm -f extended-tests-results/check-results.md
31-
@Rscript -e 'cpp4r::register("extended-tests/cpp4rtest")'
3225
@export -p USE_CLANG; /bin/bash -euo pipefail -c './scripts/check_loop.sh'
3326
@echo "==============================="
3427

@@ -37,7 +30,6 @@ bench:
3730
@rm -f extended-tests-results/bench_summary.md
3831
@$(MAKE) clean
3932
@$(MAKE) install
40-
@$(MAKE) register
4133
@export -p USE_CLANG; /bin/bash -euo pipefail -c './scripts/bench_loop.sh'
4234
@Rscript './scripts/combine-benchmarks.R'
4335

R/register.R

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,17 @@ generate_r_functions <- function(funs, package = "cpp4r", use_package = FALSE) {
223223
}
224224

225225
funs$package_call <- package_call
226-
226+
227227
# Extract default values and create parameter lists
228228
funs$param_info <- lapply(funs$args, function(args_df) {
229229
if (nrow(args_df) == 0) {
230230
return(list(params = "", args = "", checks = ""))
231231
}
232-
232+
233233
# Parse default values from the type column (they appear after '=')
234234
param_names <- args_df$name
235235
param_types <- args_df$type
236-
236+
237237
# Extract defaults (format: "type name = value" becomes "value")
238238
defaults <- vapply(param_types, function(t) {
239239
if (grepl("=", t)) {
@@ -242,12 +242,12 @@ generate_r_functions <- function(funs, package = "cpp4r", use_package = FALSE) {
242242
""
243243
}
244244
}, character(1))
245-
245+
246246
# Clean up types (remove default value parts)
247247
clean_types <- vapply(param_types, function(t) {
248248
trimws(sub("\\s*=.*$", "", t))
249249
}, character(1))
250-
250+
251251
# Generate R function parameters with defaults
252252
params_with_defaults <- vapply(seq_along(param_names), function(i) {
253253
if (nzchar(defaults[i])) {
@@ -258,24 +258,24 @@ generate_r_functions <- function(funs, package = "cpp4r", use_package = FALSE) {
258258
param_names[i]
259259
}
260260
}, character(1))
261-
261+
262262
# Generate type checking/coercion code
263263
checks <- vapply(seq_along(param_names), function(i) {
264264
generate_type_check(param_names[i], clean_types[i])
265265
}, character(1))
266266
checks <- checks[nzchar(checks)]
267-
267+
268268
list(
269269
params = paste(params_with_defaults, collapse = ", "),
270270
args = paste(param_names, collapse = ", "),
271271
checks = if (length(checks) > 0) paste0("\t", checks, collapse = "\n") else ""
272272
)
273273
})
274-
274+
275275
funs$list_params <- vapply(funs$param_info, function(x) x$params, character(1))
276276
funs$call_args <- vapply(funs$param_info, function(x) x$args, character(1))
277277
funs$type_checks <- vapply(funs$param_info, function(x) x$checks, character(1))
278-
278+
279279
funs$params <- vcapply(funs$call_args, function(x) if (nzchar(x)) paste0(", ", x) else x)
280280
is_void <- funs$return_type == "void"
281281
funs$calls <- ifelse(is_void,
@@ -308,7 +308,7 @@ generate_r_functions <- function(funs, package = "cpp4r", use_package = FALSE) {
308308
} else {
309309
paste0("\n\t", calls, "\n")
310310
}
311-
311+
312312
if (nzchar(roxygen_comment)) {
313313
glue::glue("{roxygen_comment}\n{name} <- function({list_params}) {{{body}}}")
314314
} else {
@@ -324,7 +324,7 @@ generate_r_functions <- function(funs, package = "cpp4r", use_package = FALSE) {
324324
# Helper function to convert C++ default values to R
325325
convert_cpp_default_to_r <- function(cpp_default) {
326326
cpp_default <- trimws(cpp_default)
327-
327+
328328
# Handle common cases
329329
if (cpp_default == "true" || cpp_default == "TRUE") {
330330
return("TRUE")
@@ -342,7 +342,7 @@ convert_cpp_default_to_r <- function(cpp_default) {
342342
} else if (cpp_default == "NULL" || cpp_default == "nullptr") {
343343
return("NULL")
344344
}
345-
345+
346346
# Default: keep as-is and hope for the best
347347
cpp_default
348348
}

R/template.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# which is then opened by RStudio when the new project is opened.
33

44
#' @title Start a new project with the cpp4r package template
5-
#'
5+
#'
66
#' @description This function copies a package template into a new directory.
77
#' The template includes a DESCRIPTION file, a minimal R/ directory and placeholders
88
#' with instructions. You can then edit these files to customize your new package.
9-
#'
9+
#'
1010
#' @param path Path to the new project
1111
#' @param pkgname Name of the new package
1212
#' @return The file path to the copied template (invisibly).

R/unvendor.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ unvendor <- function(path = NULL) {
5454

5555
# Remove the info file if it exists
5656
unlink(info_file_path)
57-
57+
5858
# If path does not contain any other files, remove the directory
5959
remaining_files <- list.files(path, all.files = TRUE, no.. = TRUE)
6060
if (length(remaining_files) == 0) {

dev/benchmark.R

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ rejection_bench <- map_df(
1616
cat("Target samples:", n_samples, "\n")
1717
d <- bench::mark(
1818
# "R" = { set.seed(123); cpp4rsampling::rejection_sampling(n_samples, mu = 0, sigma = 1, lower = -1.5, upper = 1.5) },
19-
"cpp4r" = { set.seed(123); cpp4rsampling::rejection_sampling_cpp4r(n_samples, mu = 0, sigma = 1, lower = -1.5, upper = 1.5) },
20-
"cpp11" = { set.seed(123); cpp11sampling::rejection_sampling_cpp11(n_samples, mu = 0, sigma = 1, lower = -1.5, upper = 1.5) },
21-
"Rcpp" = { set.seed(123); Rcppsampling::rejection_sampling_Rcpp(n_samples, mu = 0, sigma = 1, lower = -1.5, upper = 1.5) },
19+
"cpp4r" = {
20+
set.seed(123)
21+
cpp4rsampling::rejection_sampling_cpp4r(n_samples, mu = 0, sigma = 1, lower = -1.5, upper = 1.5)
22+
},
23+
"cpp11" = {
24+
set.seed(123)
25+
cpp11sampling::rejection_sampling_cpp11(n_samples, mu = 0, sigma = 1, lower = -1.5, upper = 1.5)
26+
},
27+
"Rcpp" = {
28+
set.seed(123)
29+
Rcppsampling::rejection_sampling_Rcpp(n_samples, mu = 0, sigma = 1, lower = -1.5, upper = 1.5)
30+
},
2231
iterations = 10
2332
)
2433

dev/check-urls.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ cat("\n" %in% "Checking for common redirect patterns...\n")
2727
desc_file <- "DESCRIPTION"
2828
if (file.exists(desc_file)) {
2929
desc_content <- readLines(desc_file)
30-
30+
3131
# Look for URLs in DESCRIPTION
3232
url_lines <- grep("http", desc_content, value = TRUE)
33-
33+
3434
if (length(url_lines) > 0) {
3535
cat("URLs found in DESCRIPTION:\n")
3636
for (line in url_lines) {
@@ -46,7 +46,7 @@ for (readme in readme_files) {
4646
cat(paste0("\nChecking ", readme, "...\n"))
4747
readme_content <- readLines(readme)
4848
url_lines <- grep("http", readme_content, value = TRUE)
49-
49+
5050
if (length(url_lines) > 0) {
5151
cat("URLs found:\n")
5252
for (line in url_lines) {

docs/last-updated.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"last_updated": "Last updated: 2025-11-30 09:25:47"
2+
"last_updated": "Last updated: 2025-12-05 21:21:48"
33
}

docs/vignettes/01-intro.html

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@
6969
<div id="content">
7070
<div class="content-wrapper">
7171
<div class="content-main">
72-
<h1></h1>
73-
<script src="libs/header-attrs-2.30/header-attrs.js"></script><h1 class="title toc-ignore">01 - Introduction</h1>
72+
<h1>01 - Introduction</h1>
7473

7574

7675

@@ -298,21 +297,7 @@ <h1 class="unnumbered">References</h1>
298297
</div>
299298
</div>
300299
</div>
301-
302-
303-
304-
<!-- code folding -->
305-
306-
307-
<!-- dynamically load mathjax for compatibility with self-contained -->
308-
<script>
309-
(function () {
310-
var script = document.createElement("script");
311-
script.type = "text/javascript";
312-
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
313-
document.getElementsByTagName("head")[0].appendChild(script);
314-
})();
315-
</script></div>
300+
</div>
316301
<footer><p id="last-updated">Loading...</p>
317302
</footer><script src="../js/footer.js"></script><script src="../js/theme.js"></script><script src="../js/search.js"></script><script src="../js/fontsize.js"></script></div>
318303
</div>

docs/vignettes/02-setup.html

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@
6969
<div id="content">
7070
<div class="content-wrapper">
7171
<div class="content-main">
72-
<h1></h1>
73-
<script src="libs/header-attrs-2.30/header-attrs.js"></script><h1 class="title toc-ignore">02 - Setup</h1>
72+
<h1>02 - Setup</h1>
7473

7574

7675

@@ -129,21 +128,7 @@ <h2>R Setup</h2>
129128
Running /usr/lib64/R/bin/R CMD SHLIB foo.c
130129
using C compiler: ‘gcc (GCC) 15.2.1 20250813’</code></pre>
131130
</div>
132-
133-
134-
135-
<!-- code folding -->
136-
137-
138-
<!-- dynamically load mathjax for compatibility with self-contained -->
139-
<script>
140-
(function () {
141-
var script = document.createElement("script");
142-
script.type = "text/javascript";
143-
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
144-
document.getElementsByTagName("head")[0].appendChild(script);
145-
})();
146-
</script></div>
131+
</div>
147132
<footer><p id="last-updated">Loading...</p>
148133
</footer><script src="../js/footer.js"></script><script src="../js/theme.js"></script><script src="../js/search.js"></script><script src="../js/fontsize.js"></script></div>
149134
</div>

0 commit comments

Comments
 (0)