Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rstantools v2.4.0 #118

Merged
merged 6 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/check-standalone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ jobs:

- name: Checkout lgpr package
run: |
git clone https://github.com/andrjohns/lgpr
cd lgpr && git checkout array-syntax
git clone https://github.com/jtimonen/lgpr

- name: Check against CRAN StanHeaders and CRAN RStan
run: |
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: rstantools
Type: Package
Title: Tools for Developing R Packages Interfacing with 'Stan'
Version: 2.3.1.1
Date: 2023-07-18
Version: 2.4.0
Date: 2024-01-22
Authors@R:
c(person(given = "Jonah",
family = "Gabry",
Expand Down Expand Up @@ -53,6 +53,6 @@ Suggests:
roxygen2 (>= 6.0.1),
rmarkdown,
rstudioapi
RoxygenNote: 7.2.3
RoxygenNote: 7.3.0
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export(predictive_interval)
export(prior_summary)
export(rstan_config)
export(rstan_create_package)
export(rstantools_load_code)
export(use_rstan)
importFrom(RcppParallel,RcppParallelLibs)
importFrom(stats,quantile)
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# rstantools 2.4.0

* Update to match CRAN's patched version by @jgabry in #114
* Include additional template imports to suppress NOTEs by @andrjohns in #115
* Fix packages with stanfunctions under rstan 2.33+ by @andrjohns in #117


# rstantools 2.3.1

* Deprecated `init_cpp`. (#105)
Expand Down
2 changes: 1 addition & 1 deletion R/rstan_create_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#' @param stan_files A character vector with paths to `.stan` files to include
#' in the package.
#' @param roxygen Should \pkg{roxygen2} be used for documentation? Defaults to
#' `TRUE`. If so, a file `R/{pkgname}-package.R`` is added to the package with
#' `TRUE`. If so, a file `R/{pkgname}-package.R` is added to the package with
#' roxygen tags for the required import lines. See the **Note** section below
#' for advice specific to the latest versions of \pkg{roxygen2}.
#' @param travis Should a `.travis.yml` file be added to the package directory?
Expand Down
21 changes: 21 additions & 0 deletions R/rstan_package_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,24 @@
}
invisible(acc)
}

#' Helper function for loading code in roxygenise
#'
#' Adapted from the \code{sourceDir} function defined
#' by \code{example(source)}.
#'
#' @param path Path to directory containing code to load
#' @param trace Whether to print file names as they are loaded
#' @param ... Additional arguments passed to \code{\link{source}}
#'
#' @return \code{NULL}
#' @export
rstantools_load_code <- function(path, trace = TRUE, ...) {
op <- options(); on.exit(options(op)) # to reset after each
for (nm in list.files(path, pattern = "[.][RrSsQq]$")) {
if (trace) cat(nm, ":")
source(file.path(path, nm), ...)
if (trace) cat("\n")
options(op)
}
}
2 changes: 1 addition & 1 deletion man/rstan_create_package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions man/rstantools-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions man/rstantools_load_code.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/use_rstan.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions tests/testthat/test-rstan_create_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ for(ii in 1:ntest) {
skip_on_cran()
skip_on_travis()
}
example(source) # defines the sourceDir() function
try(roxygen2::roxygenize(pkg_dest_path, load_code = sourceDir), silent = TRUE)
try(roxygen2::roxygenize(pkg_dest_path, load_code = rstantools_load_code), silent = TRUE)
pkgbuild::compile_dll(pkg_dest_path)
tmp <- capture.output(load_out <- pkgload::load_all(pkg_dest_path,
export_all = TRUE,
Expand Down
7 changes: 2 additions & 5 deletions vignettes/minimal-rstan-package.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,12 @@ for `lm_stan` and update the `NAMESPACE` so the function is exported, i.e.,
available to users when the package is installed. This can be done with the
function `roxygen2::roxygenize()`, which needs to be called twice initially.

```{r, results = "hide"}
example(source) # defines the sourceDir() function
```
```{r, eval = FALSE}
try(roxygen2::roxygenize(load_code = sourceDir), silent = TRUE)
try(roxygen2::roxygenize(load_code = rstantools_load_code), silent = TRUE)
roxygen2::roxygenize()
```
```{r, echo=FALSE, results="hide"}
try(roxygen2::roxygenize(PATH, load_code = sourceDir), silent = TRUE)
try(roxygen2::roxygenize(PATH, load_code = rstantools_load_code), silent = TRUE)
roxygen2::roxygenize(PATH)
```

Expand Down