Skip to content

Commit

Permalink
Slightly better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
marberts committed Oct 26, 2023
1 parent 1871fec commit 8debf75
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: sps
Title: Sequential Poisson Sampling
Version: 0.5.3.9001
Version: 0.5.3.9002
Authors@R: c(
person("Steve", "Martin", role = c("aut", "cre", "cph"), email = "stevemartin041@gmail.com", comment = c(ORCID = "0000-0003-2544-9480")),
person("Justin", "Francis", role = "ctb")
Expand Down
4 changes: 2 additions & 2 deletions R/prop_allocation.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' Highest-averages apportionment method
#' @noRd
highest_averages <- function(p, n, initial, available, ties, dist) {
if (n < 0L) {
stop("sample size must be greater than or equal to 0")
if (length(n) > 1L || n < 0L) {
stop("sample size must be an integer greater than or equal to 0")
}
if (length(p) != length(initial)) {
stop("initial allocation must have a single size for each stratum")
Expand Down
8 changes: 4 additions & 4 deletions R/sps_repweights.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ sps_repweights <- function(w, replicates = 1000L, tau = 1, dist = NULL) {
}

replicates <- as.integer(replicates)
if (replicates < 0L) {
stop("number of replicates must be greater than or equal to 0")
if (length(replicates) > 1L || replicates < 0L) {
stop("number of replicates must be an integer greater than or equal to 0")
}

tau <- as.numeric(tau)
if (tau < 1) {
stop("'tau' must be greater than or equal to 1")
if (length(tau) > 1L || tau < 1) {
stop("'tau' must be number greater than or equal to 1")
}

p <- 1 / w
Expand Down

0 comments on commit 8debf75

Please sign in to comment.