Skip to content

Commit

Permalink
0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Aug 8, 2023
1 parent 561c4a2 commit 121af6f
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 139 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@
^paper\.bib$
^NOTICE$
^cmdstan$
^tests/testthat/test-stan_package_model\.R$
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Description: Similar to 'rstantools' for 'rstan',
and setting environment variables.
Packages 'rstantools', 'cmdstanr', 'stannis', and
'stanapi' are similar Stan clients with different objectives.
Version: 0.0.1.9000
Version: 0.0.2
License: MIT + file LICENSE
URL: https://wlandau.github.io/instantiate/,
https://github.com/wlandau/instantiate
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# instantiate 0.0.1.9000 (development)

# instantiate 0.0.2

* Address CRAN comments from the submission of version 0.0.1.

# instantiate 0.0.1

Expand Down
22 changes: 6 additions & 16 deletions R/stan_package_clean.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,16 @@
#' @inheritParams stan_package_compile
#' @examples
#' if (identical(Sys.getenv("INSTANTIATE_EXAMPLES"), "true")) {
#' # Compilation happens automatically when the package installs.
#' path <- tempfile()
#' stan_package_create(path = path)
#' stan_package_configure(path = path)
#' temporary_library <- tempfile()
#' dir.create(temporary_library)
#' install.packages(
#' pkgs = path,
#' lib = temporary_library,
#' type = "source",
#' repos = NULL
#' )
#' # But if you want to manually compile a directory of Stan files,
#' # you can call stan_package_compile() directly like this:
#' path <- file.path(path, "inst", "stan")
#' stan_package_compile(path = path)
#' list.files(path)
#' models <- stan_package_model_files(path)
#' list.files(file.path(path, "inst", "stan"))
#' stan_package_compile(models)
#' list.files(file.path(path, "inst", "stan"))
#' # Clean up the compiled Stan model files:
#' stan_package_clean(path = path)
#' list.files(path)
#' stan_package_clean(models = models)
#' list.files(file.path(path, "inst", "stan"))
#' }
stan_package_clean <- function(
models = instantiate::stan_package_model_files()
Expand Down
16 changes: 4 additions & 12 deletions R/stan_package_compile.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,13 @@
#' to model control compilation.
#' @examples
#' if (identical(Sys.getenv("INSTANTIATE_EXAMPLES"), "true")) {
#' # Compilation happens automatically when the package installs.
#' path <- tempfile()
#' stan_package_create(path = path)
#' stan_package_configure(path = path)
#' temporary_library <- tempfile()
#' dir.create(temporary_library)
#' install.packages(
#' pkgs = path,
#' lib = temporary_library,
#' type = "source",
#' repos = NULL
#' )
#' # But if you want to manually compile a directory of Stan files,
#' # you can call stan_package_compile() directly like this:
#' stan_package_compile(path = file.path(path, "inst", "stan"))
#' models <- stan_package_model_files(path)
#' list.files(file.path(path, "inst", "stan"))
#' stan_package_compile(models)
#' list.files(file.path(path, "inst", "stan"))
#' }
stan_package_compile <- function(
models = instantiate::stan_package_model_files(),
Expand Down
10 changes: 2 additions & 8 deletions R/stan_package_configure.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@
#' if (identical(Sys.getenv("INSTANTIATE_EXAMPLES"), "true")) {
#' path <- tempfile()
#' stan_package_create(path = path)
#' list.files(path)
#' stan_package_configure(path = path)
#' temporary_library <- tempfile()
#' dir.create(temporary_library)
#' install.packages(
#' pkgs = path,
#' lib = temporary_library,
#' type = "source",
#' repos = NULL
#' )
#' list.files(path)
#' }
stan_package_configure <- function(path = getwd(), overwrite = FALSE) {
stan_assert(
Expand Down
10 changes: 1 addition & 9 deletions R/stan_package_create.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@
#' if (identical(Sys.getenv("INSTANTIATE_EXAMPLES"), "true")) {
#' path <- tempfile()
#' stan_package_create(path = path)
#' stan_package_configure(path = path)
#' temporary_library <- tempfile()
#' dir.create(temporary_library)
#' install.packages(
#' pkgs = path,
#' lib = temporary_library,
#' type = "source",
#' repos = NULL
#' )
#' list.files(path)
#' }
stan_package_create <- function(path = tempfile()) {
stan_assert(
Expand Down
23 changes: 4 additions & 19 deletions R/stan_package_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#' @details Packages configured with `instantiate` compile their Stan
#' models on installation. Then the `stan_package_model()` function
#' retrieves the `cmdstanr::cmdstan_model()` object without needing
#' to re-compile the model.
#' to re-compile the model. Please see the documentation website
#' of the `instantiate` package for examples.
#' @return An `R6` Stan model object from the `cmdstanr` package.
#' Please visit the documentation website at <https://mc-stan.org/cmdstanr/>
#' for detailed information on the composition of this model object
Expand All @@ -20,24 +21,8 @@
#' to look for the package with the built-in Stan model.
#' Passed to the `lib.loc` argument of `system.file()`.
#' @examples
#' if (identical(Sys.getenv("INSTANTIATE_EXAMPLES"), "true")) {
#' path <- tempfile()
#' stan_package_create(path = path)
#' stan_package_configure(path = path)
#' temporary_library <- tempfile()
#' dir.create(temporary_library)
#' install.packages(
#' pkgs = path,
#' lib = temporary_library,
#' type = "source",
#' repos = NULL
#' )
#' model <- stan_package_model(
#' name = "bernoulli",
#' package = "example",
#' library = temporary_library
#' )
#' }
#' # Please see the documentation website of the {instantiate} package
#' # for examples.
stan_package_model <- function(
name,
package,
Expand Down
12 changes: 4 additions & 8 deletions R/utils_assert.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,10 @@ stan_assert_cmdstanr <- function() {
pkg = "cmdstanr",
reason = paste(
"The {cmdstanr} package is needed to install",
"CmdStan and run Stan models."
),
action = function(pkg, ...) {
install.packages(
pkgs = "cmdstanr",
repos = c("https://mc-stan.org/r-packages/", getOption("repos"))
)
}
"CmdStan and run Stan models. Please install it manually using",
"install.packages(pkgs = \"cmdstanr\",",
"repos = c(\"https://mc-stan.org/r-packages/\", getOption(\"repos\"))"
)
),
error = function(e) {
stan_error(conditionMessage(e))
Expand Down
22 changes: 6 additions & 16 deletions man/stan_package_clean.Rd

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

16 changes: 4 additions & 12 deletions man/stan_package_compile.Rd

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

10 changes: 2 additions & 8 deletions man/stan_package_configure.Rd

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

10 changes: 1 addition & 9 deletions man/stan_package_create.Rd

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

23 changes: 4 additions & 19 deletions man/stan_package_model.Rd

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

0 comments on commit 121af6f

Please sign in to comment.