Skip to content
Open
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
6 changes: 3 additions & 3 deletions R/frequency.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ get_frequencies.NULL <- function(period, data, ...,
#' @rdname freq_tools
#' @export
get_frequencies.character <- function(period, data, ...){
require_package("lubridate")
check_installed("lubridate")
m <- lubridate::as.period(period)
if(is.na(m)) abort(paste("Unknown period:", period))
get_frequencies(m, data, ...)
Expand All @@ -96,7 +96,7 @@ get_frequencies.character <- function(period, data, ...){
#' @rdname freq_tools
#' @export
get_frequencies.Period <- function(period, data, ...){
require_package("lubridate")
check_installed("lubridate")

interval <- tsibble::interval(data)

Expand All @@ -107,4 +107,4 @@ get_frequencies.Period <- function(period, data, ...){
lubridate::microseconds(microsecond) + lubridate::nanoseconds(nanosecond))

suppressMessages(period / interval)
}
}
4 changes: 2 additions & 2 deletions R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Check that specified model(s) are model definitions.", nm[which(!is_mdl)[1]]))
}

if(is_attached("package:future")){
require_package("future.apply")
check_installed("future.apply")
eval_models <- function(models, lst_data){
out <- future.apply::future_mapply(
rep(lst_data, length(models)),
Expand Down Expand Up @@ -183,4 +183,4 @@ model_rhs <- function(model){
else{
expr(NULL)
}
}
}
2 changes: 1 addition & 1 deletion R/model_decomposition.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Please specify an appropriate model for these components",
}

mdls_default <- if(!is_empty(miss_vars)){
require_package("fable")
check_installed("fable")
lag <- NULL

structure[miss_vars] %>%
Expand Down
4 changes: 2 additions & 2 deletions R/reconciliation.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ forecast.lst_mint_mdl <- function(object, key_data,
method <- object%@%"method"
sparse <- object%@%"sparse"
if(sparse){
require_package("Matrix")
check_installed("Matrix")
as.matrix <- Matrix::as.matrix
t <- Matrix::t
diag <- function(x) if(is.vector(x)) Matrix::Diagonal(x = x) else Matrix::diag(x)
Expand Down Expand Up @@ -467,7 +467,7 @@ reconcile_fbl_list <- function(fc, S, P, W, point_forecast, SP = NULL) {
}
if(!inherits(S, "matrix")) {
# Use sparse functions
require_package("Matrix")
check_installed("Matrix")
as.matrix <- Matrix::as.matrix
t <- Matrix::t
diag <- function(x) if(is.vector(x)) Matrix::Diagonal(x = x) else Matrix::diag(x)
Expand Down
10 changes: 1 addition & 9 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ big_mark <- function (x, ...) {
ret
}

require_package <- function(pkg){
if(!requireNamespace(pkg, quietly = TRUE)){
abort(
sprintf('The `%s` package must be installed to use this functionality. It can be installed with install.packages("%s")', pkg, pkg)
)
}
}

calc <- function(f, ...){
f(...)
}
Expand Down Expand Up @@ -262,7 +254,7 @@ mapply_maybe_parallel <- function (.f, ..., MoreArgs = list(), SIMPLIFY = FALSE)
.f(...)
}
if(is_attached("package:future")){
require_package("future.apply")
check_installed("future.apply")
future.apply::future_mapply(
FUN = .fp,
...,
Expand Down