Skip to content

Commit 0989e12

Browse files
committed
chore: clean-up assertions
1 parent 890fc10 commit 0989e12

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

R/assertions.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
is_count <- function(x, null_ok = FALSE) {
2+
if (null_ok && is.null(x)) {
3+
return(TRUE)
4+
}
5+
is.numeric(x) && length(x) == 1L && !is.na(x) && as.integer(x) == x && x > 0L
6+
}

R/utils.R

Lines changed: 0 additions & 7 deletions
This file was deleted.

R/yield-curve.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ tr_curve_rate <- function(
3838
if (requireNamespace("readxl", quietly = TRUE)) {
3939
stop("Please install the readxl package to use this function.", call. = FALSE)
4040
}
41-
stopifnot(is_count_or_null(year))
41+
stopifnot(is_count(year, null_ok = TRUE))
4242
x <- match.arg(x)
4343
type <- match.arg(type)
4444
start_year <- switch(x, hqm = 1984L, tnc = 1978L, trc = 2003L, tbi = 2003L)

0 commit comments

Comments
 (0)