Skip to content

Commit

Permalink
Fix 'an' to 'a'
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Aug 21, 2024
1 parent e00e148 commit ecef2cd
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions R/combine.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
##'
##' @param b The second model
##'
##' @param properties An [monty_model_properties] object, used to
##' @param properties A [monty_model_properties] object, used to
##' control (or enforce) properties of the combined model.
##'
##' @param name_a Name of the first model (defaulting to 'a'); you can
Expand All @@ -62,7 +62,7 @@
##' use this to make error messages nicer to read, but it has no
##' other practical effect.
##'
##' @return An [monty_model] object
##' @return A [monty_model] object
##'
##' @export
monty_model_combine <- function(a, b, properties = NULL,
Expand Down
4 changes: 2 additions & 2 deletions R/dsl-generate.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dsl_generate_density_expr <- function(expr, env, density) {
stochastic = dsl_generate_density_stochastic(expr, env, density),
cli::cli_abort(paste(
"Unimplemented expression type '{expr$type}';",
"this is an monty bug")))
"this is a monty bug")))
}


Expand All @@ -71,7 +71,7 @@ dsl_generate_sample_expr <- function(expr, env, result) {
stochastic = dsl_generate_sample_stochastic(expr, env),
cli::cli_abort(paste(
"Unimplemented expression type '{expr$type}';",
"this is an monty bug")))
"this is a monty bug")))
}


Expand Down
8 changes: 4 additions & 4 deletions R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ monty_model_properties <- function(has_gradient = NULL,
##' `(-Inf, Inf)`.
##'
##' * `direct_sample`: A function to sample directly from the
##' parameter space, given an [monty_rng] object to sample from.
##' parameter space, given a [monty_rng] object to sample from.
##' In the case where a model returns a posterior (e.g., in Bayesian
##' inference), this is assumed to be sampling from the prior.
##' We'll use this for generating initial conditions for MCMC where
Expand Down Expand Up @@ -198,11 +198,11 @@ monty_model <- function(model, properties = NULL) {


##' Compute log density for a model. This is a wrapper around the
##' `$density` property within an [monty_model] object.
##' `$density` property within a [monty_model] object.
##'
##' @title Compute log density
##'
##' @param model An [monty_model] object
##' @param model A [monty_model] object
##'
##' @param parameters A vector or matrix of parameters
##'
Expand Down Expand Up @@ -469,7 +469,7 @@ validate_model_parameter_groups <- function(model, properties, call) {
require_monty_model <- function(model, arg = deparse(substitute(model)),
call = parent.frame()) {
if (!inherits(model, "monty_model")) {
cli::cli_abort("Expected '{arg}' to be an 'monty_model'",
cli::cli_abort("Expected '{arg}' to be a 'monty_model'",
arg = arg, call = call)
}
}
Expand Down
10 changes: 5 additions & 5 deletions R/sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ monty_sample <- function(model, sampler, n_steps, initial = NULL,
restartable = FALSE) {
require_monty_model(model)
if (!inherits(sampler, "monty_sampler")) {
cli::cli_abort("Expected 'sampler' to be an 'monty_sampler'",
cli::cli_abort("Expected 'sampler' to be a 'monty_sampler'",
arg = "sampler")
}
if (is.null(runner)) {
runner <- monty_runner_serial()
}
if (!is.null(observer) && !inherits(observer, "monty_observer")) {
cli::cli_abort("Expected 'observer' to be an 'monty_observer'",
cli::cli_abort("Expected 'observer' to be a 'monty_observer'",
arg = "observer")
}
if (!inherits(runner, "monty_runner")) {
cli::cli_abort("Expected 'runner' to be an 'monty_runner'",
cli::cli_abort("Expected 'runner' to be a 'monty_runner'",
arg = "runner")
}

Expand Down Expand Up @@ -116,7 +116,7 @@ monty_sample <- function(model, sampler, n_steps, initial = NULL,
##' this function). You can use this argument to change the runner,
##' which might be useful if transferring a pilot run from a
##' high-resource environment to a lower-resource environment. If
##' given, must be an `monty_runner` object such as
##' given, must be a `monty_runner` object such as
##' [monty_runner_serial] or [monty_runner_parallel]. You can
##' use this argument to change the configuration of a runner, as
##' well as the type of runner (e.g., changing the number of
Expand All @@ -129,7 +129,7 @@ monty_sample <- function(model, sampler, n_steps, initial = NULL,
monty_sample_continue <- function(samples, n_steps, restartable = FALSE,
runner = NULL) {
if (!inherits(samples, "monty_samples")) {
cli::cli_abort("Expected 'samples' to be an 'monty_samples' object")
cli::cli_abort("Expected 'samples' to be a 'monty_samples' object")
}
if (is.null(samples$restart)) {
cli::cli_abort(
Expand Down
2 changes: 1 addition & 1 deletion inst/include/monty/r/random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ SEXP rng_pointer_init(int n_streams, cpp11::sexp r_seed, int long_jump) {
///
/// @tparam rng_state_type The random number state type to use
///
/// @param obj An `monty_rng_pointer` object, created in R with
/// @param obj A `monty_rng_pointer` object, created in R with
/// ``monty::monty_rng_pointer``
///
/// @param n_streams The number of required streams. Set this to 0 to
Expand Down
2 changes: 1 addition & 1 deletion man/monty_model.Rd

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

4 changes: 2 additions & 2 deletions man/monty_model_combine.Rd

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

4 changes: 2 additions & 2 deletions man/monty_model_density.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/monty_model_direct_sample.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/monty_model_gradient.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/monty_sample_continue.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/test-combine.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ test_that("validate input args", {
x <- ex_simple_gamma1()
expect_error(
monty_model_combine(x, NULL),
"Expected 'b' to be an 'monty_model'")
"Expected 'b' to be a 'monty_model'")
expect_error(
monty_model_combine(NULL, x),
"Expected 'a' to be an 'monty_model'")
"Expected 'a' to be a 'monty_model'")
expect_error(
monty_model_combine(x, x, TRUE),
"Expected 'properties' to be a 'monty_model_properties' object")
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-dsl-generate.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
test_that("throw useful error if we have new unimplemented expression types", {
expect_error(
dsl_generate_density_expr(list(type = "magic")),
"Unimplemented expression type 'magic'; this is an monty bug")
"Unimplemented expression type 'magic'; this is a monty bug")
expect_error(
dsl_generate_sample_expr(list(type = "magic")),
"Unimplemented expression type 'magic'; this is an monty bug")
"Unimplemented expression type 'magic'; this is a monty bug")
})
10 changes: 5 additions & 5 deletions tests/testthat/test-sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ test_that("can validate sample inputs", {
model <- ex_simple_gamma1()
sampler <- monty_sampler_random_walk(vcv = diag(1) * 0.01)
expect_error(monty_sample(NULL, NULL, 100),
"Expected 'model' to be an 'monty_model'")
"Expected 'model' to be a 'monty_model'")
expect_error(monty_sample(model, NULL, 100),
"Expected 'sampler' to be an 'monty_sampler'")
"Expected 'sampler' to be a 'monty_sampler'")
expect_error(monty_sample(model, sampler, 100, runner = TRUE),
"Expected 'runner' to be an 'monty_runner'")
"Expected 'runner' to be a 'monty_runner'")
expect_error(monty_sample(model, sampler, 100, observer = TRUE),
"Expected 'observer' to be an 'monty_observer'")
"Expected 'observer' to be a 'monty_observer'")
expect_error(monty_sample(model, sampler, 100, c(1, 2)),
"Unexpected length for vector 'initial' (given 2, expected 1)",
fixed = TRUE)
Expand Down Expand Up @@ -197,7 +197,7 @@ test_that("can't restart chains that don't have restart information", {
test_that("continuing requires that we have a samples object", {
model <- ex_simple_gamma1()
expect_error(monty_sample_continue(model, 50),
"Expected 'samples' to be an 'monty_samples' object")
"Expected 'samples' to be a 'monty_samples' object")
})


Expand Down
2 changes: 1 addition & 1 deletion vignettes/dsl.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ We can compute the domain for your model:
prior$domain
```

We can draw samples from the model if we provide an [monty_rng] object
We can draw samples from the model if we provide a `monty_rng` object

```{r}
rng <- monty_rng$new()
Expand Down
2 changes: 1 addition & 1 deletion vignettes/monty.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ library(monty)

Draw samples from a model using Markov Chain Monte Carlo methods. To do this you will need:

* A **model**: this is an `monty_model()` object and minimally knows about the names of its parameter vector (which is an unstructured real-valued vector) and can compute a log probability density. It may also be able to compute a gradient of this log density, or sample directly from parameter space (e.g., if it represents a prior distribution).
* A **model**: this is a `monty_model()` object and minimally knows about the names of its parameter vector (which is an unstructured real-valued vector) and can compute a log probability density. It may also be able to compute a gradient of this log density, or sample directly from parameter space (e.g., if it represents a prior distribution).
* A **sampler**: this is some method of drawing samples from the model's distribution in a sequence. We define several different sampler types, with the simplest one being `monty_sampler_random_walk()`, which implements a simple Metropolis algorithm random walk.
* A **runner**: this controls how the chains will be run (e.g., one after another or in parallel).

Expand Down
2 changes: 1 addition & 1 deletion vignettes/samples.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ library(monty)

# The structure of monty samples

All samplers and runners produce samples with the same basic structure. This structure is documented (here) so you are free to use this structure if you want to just dive in and manipulate things. Please treat output as read-only; extract data all you want, but make a copy and don't change any value within the samples structure if you are going to pass it back into an `monty` function, as we assume that they have not been modified.
All samplers and runners produce samples with the same basic structure. This structure is documented (here) so you are free to use this structure if you want to just dive in and manipulate things. Please treat output as read-only; extract data all you want, but make a copy and don't change any value within the samples structure if you are going to pass it back into a `monty` function, as we assume that they have not been modified.

```{r, include = FALSE}
# This is the example from before samplers.Rmd; at some point we will
Expand Down

0 comments on commit ecef2cd

Please sign in to comment.