Skip to content

Commit 3658b26

Browse files
authored
Drop ellipsis for rlang + use check_installed() to install packages on the fly (#37)
* Drop ellipsis for rlang * Use `rlang::check_installed()` to install missing packages on the fly.
1 parent b0c46a4 commit 3658b26

9 files changed

+13
-41
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ Depends:
2626
Matrix
2727
Imports:
2828
dplyr,
29-
ellipsis,
3029
ggplot2,
3130
glue,
3231
igraph,
3332
methods,
33+
rlang (>= 1.0.0),
3434
RSpectra,
3535
stats,
3636
tibble,

R/directed_factor_model.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ new_directed_factor_model <- function(
44
allow_self_loops,
55
...,
66
subclass = character()) {
7-
ellipsis::check_dots_unnamed()
7+
rlang::check_dots_unnamed()
88

99
n <- nrow(X)
1010
k1 <- ncol(X)

R/expected-degrees.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
#' svds(dfm)
7070
#'
7171
expected_edges <- function(factor_model, ...) {
72-
ellipsis::check_dots_empty()
72+
rlang::check_dots_empty()
7373
UseMethod("expected_edges")
7474
}
7575

R/expected-spectra.R

+3-18
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ eigs_sym.undirected_factor_model <- function(
2020
which = "LM", sigma = NULL,
2121
opts = list(),
2222
...) {
23-
if (!requireNamespace("RSpectra", quietly = TRUE)) {
24-
stop(
25-
"Must install `RSpectra` for this functionality.",
26-
call. = FALSE
27-
)
28-
}
23+
rlang::check_installed("RSpectra")
2924

3025
Ax <- function(x, args) as.numeric(args$X %*% (args$SXt %*% x))
3126

@@ -48,12 +43,7 @@ svds.undirected_factor_model <- function(
4843
nv = k,
4944
opts = list(),
5045
...) {
51-
if (!requireNamespace("RSpectra", quietly = TRUE)) {
52-
stop(
53-
"Must install `RSpectra` for this functionality.",
54-
call. = FALSE
55-
)
56-
}
46+
rlang::check_installed("RSpectra")
5747

5848
Ax <- function(x, args) {
5949
as.numeric(args$X %*% (tcrossprod(args$S, args$X) %*% x))
@@ -92,12 +82,7 @@ svds.directed_factor_model <- function(
9282
nv = k,
9383
opts = list(),
9484
...) {
95-
if (!requireNamespace("RSpectra", quietly = TRUE)) {
96-
stop(
97-
"Must install `RSpectra` for this functionality.",
98-
call. = FALSE
99-
)
100-
}
85+
rlang::check_installed("RSpectra")
10186

10287
Ax <- function(x, args) {
10388
as.numeric(args$X %*% (tcrossprod(args$S, args$Y) %*% x))

R/sample_edgelist.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
sample_edgelist <- function(
147147
factor_model,
148148
...) {
149-
ellipsis::check_dots_unnamed()
149+
rlang::check_dots_unnamed()
150150
UseMethod("sample_edgelist")
151151
}
152152

R/sample_igraph.R

+2-8
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,9 @@
2727
sample_igraph <- function(
2828
factor_model,
2929
...) {
30-
ellipsis::check_dots_unnamed()
30+
rlang::check_dots_unnamed()
3131

32-
if (!(requireNamespace("igraph", quietly = TRUE))) {
33-
stop(
34-
"Must install `igraph` package to return graphs as `igraph` ",
35-
"objects",
36-
call. = FALSE
37-
)
38-
}
32+
rlang::check_installed("igraph", "to return graphs as `igraph` objects.")
3933

4034
UseMethod("sample_igraph")
4135
}

R/sample_sparse.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
sample_sparse <- function(
2525
factor_model,
2626
...) {
27-
ellipsis::check_dots_unnamed()
27+
rlang::check_dots_unnamed()
2828
UseMethod("sample_sparse")
2929
}
3030

R/sample_tidygraph.R

+2-9
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,8 @@
2727
sample_tidygraph <- function(
2828
factor_model,
2929
...) {
30-
ellipsis::check_dots_unnamed()
31-
32-
if (!(requireNamespace("tidygraph", quietly = TRUE))) {
33-
stop(
34-
"Must install `tidygraph` package to return graphs as `tidygraph` ",
35-
"objects",
36-
call. = FALSE
37-
)
38-
}
30+
rlang::check_dots_unnamed()
31+
rlang::check_installed("igraph", "to return graphs as `tidygraph` objects.")
3932

4033
UseMethod("sample_tidygraph")
4134
}

R/undirected_factor_model.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ new_undirected_factor_model <- function(
44
poisson_edges = TRUE,
55
allow_self_loops = TRUE,
66
subclass = character()) {
7-
ellipsis::check_dots_unnamed()
7+
rlang::check_dots_unnamed()
88

99
n <- nrow(X)
1010
k <- ncol(S)

0 commit comments

Comments
 (0)