From 9af54e489481619bb9a988b5ac7f0d062b06c5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 16 May 2023 10:52:14 +0200 Subject: [PATCH 1/9] refactor!: kill igraph.arpack.default and arpack_defaults lists, add arpack_defaults() as a function --- R/centrality.R | 33 +++++++++++++++++++++++---------- R/community.R | 20 ++++++++++++++++---- R/embedding.R | 4 ++-- R/layout.R | 15 ++++++++++++++- R/layout_drl.R | 4 +--- R/utils.R | 9 +++++++++ R/zzz-deprecate.R | 2 -- tools/stimulus/types-RR.yaml | 6 +++--- 8 files changed, 68 insertions(+), 25 deletions(-) diff --git a/R/centrality.R b/R/centrality.R index 3ed4e03ca40..ee8b3c461b2 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -318,11 +318,13 @@ closeness.estimate <- estimate_closeness #' @rdname arpack #' @family arpack #' @export -arpack_defaults <- list( - bmat = "I", n = 0, which = "XX", nev = 1, tol = 0.0, - ncv = 3, ldv = 0, ishift = 1, maxiter = 3000, nb = 1, - mode = 1, start = 0, sigma = 0.0, sigmai = 0.0 -) +arpack_defaults <- function() { + list( + bmat = "I", n = 0, which = "XX", nev = 1, tol = 0.0, + ncv = 3, ldv = 0, ishift = 1, maxiter = 3000, nb = 1, + mode = 1, start = 0, sigma = 0.0, sigmai = 0.0 + ) +} #' ARPACK eigenvector calculation #' @@ -431,7 +433,7 @@ arpack_defaults <- list( #' re-orthogonalization.} } } Please see the ARPACK documentation for #' additional details. #' -#' @aliases arpack arpack-options igraph.arpack.default arpack.unpack.complex +#' @aliases arpack arpack-options arpack.unpack.complex #' arpack_defaults #' @param func The function to perform the matrix-vector multiplication. ARPACK #' requires to perform these by the user. The function gets the vector \eqn{x} @@ -512,8 +514,21 @@ arpack_defaults <- list( #' } #' @family arpack #' @export -arpack <- function(func, extra = NULL, sym = FALSE, options = arpack_defaults, +arpack <- function(func, extra = NULL, sym = FALSE, options = arpack_defaults(), env = parent.frame(), complex = !sym) { + + eval_try <- rlang::eval_tidy(options) + options_value <- rlang::call_args(rlang::current_call())[["options"]] + if (is(eval_try, "function") && as.character(options_value) == "arpack_defaults") { + lifecycle::deprecate_soft( + "1.5.0", + I("arpack_defaults"), + "arpack_defaults()", + details = c("So the function arpack_defaults(), not an object called arpack_defaults.") + ) + options <- arpack_defaults() + } + if (!is.list(options) || (is.null(names(options)) && length(options) != 0)) { stop("options must be a named list") @@ -530,9 +545,7 @@ arpack <- function(func, extra = NULL, sym = FALSE, options = arpack_defaults, ) } - options.tmp <- arpack_defaults - options.tmp[names(options)] <- options - options <- options.tmp + options <- modify_list(arpack_defaults(), options) if (sym && complex) { complex <- FALSE diff --git a/R/community.R b/R/community.R index 4a111126cee..bc9f648d5ee 100644 --- a/R/community.R +++ b/R/community.R @@ -1621,9 +1621,22 @@ igraph.i.levc.arp <- function(externalP, externalE) { #' cluster_leading_eigen <- function(graph, steps = -1, weights = NULL, start = NULL, - options = arpack_defaults, + options = arpack_defaults(), callback = NULL, extra = NULL, env = parent.frame()) { + + eval_try <- rlang::eval_tidy(options) + options_value <- rlang::call_args(rlang::current_call())[["options"]] + if (is(eval_try, "function") && as.character(options_value) == "arpack_defaults") { + lifecycle::deprecate_soft( + "1.5.0", + I("arpack_defaults"), + "arpack_defaults()", + details = c("So the function arpack_defaults(), not an object called arpack_defaults.") + ) + options <- arpack_defaults() + } + # Argument checks ensure_igraph(graph) @@ -1639,9 +1652,8 @@ cluster_leading_eigen <- function(graph, steps = -1, weights = NULL, if (!is.null(start)) { start <- as.numeric(start) - 1 } - options.tmp <- arpack_defaults - options.tmp[names(options)] <- options - options <- options.tmp + + options <- modify_list(arpack_defaults(), options) on.exit(.Call(R_igraph_finalizer)) # Function call diff --git a/R/embedding.R b/R/embedding.R index 5e402ab64c1..809ec0ce57f 100644 --- a/R/embedding.R +++ b/R/embedding.R @@ -65,7 +65,7 @@ #' graph. This vector is added to the diagonal of the adjacency matrix. #' @param options A named list containing the parameters for the SVD #' computation algorithm in ARPACK. By default, the list of values is assigned -#' the values given by [igraph.arpack.default]. +#' the values given by [arpack_defaults()]. #' @return A list containing with entries: \item{X}{Estimated latent positions, #' an `n` times `no` matrix, `n` is the number of vertices.} #' \item{Y}{`NULL` for undirected graphs, the second half of the latent @@ -203,7 +203,7 @@ dim_select <- dim_select_impl #' returned instead of \eqn{X} and \eqn{Y}. #' @param options A named list containing the parameters for the SVD #' computation algorithm in ARPACK. By default, the list of values is assigned -#' the values given by [igraph.arpack.default]. +#' the values given by [arpack_defaults()]. #' @return A list containing with entries: \item{X}{Estimated latent positions, #' an `n` times `no` matrix, `n` is the number of vertices.} #' \item{Y}{`NULL` for undirected graphs, the second half of the latent diff --git a/R/layout.R b/R/layout.R index 92d537f8162..3f4da60ef0f 100644 --- a/R/layout.R +++ b/R/layout.R @@ -1517,7 +1517,20 @@ layout.lgl <- function(..., params = list()) { #' l <- layout_with_mds(g) #' plot(g, layout = l, vertex.label = NA, vertex.size = 3) layout_with_mds <- function(graph, dist = NULL, dim = 2, - options = arpack_defaults) { + options = arpack_defaults()) { + + eval_try <- rlang::eval_tidy(options) + options_value <- rlang::call_args(rlang::current_call())[["options"]] + if (is(eval_try, "function") && as.character(options_value) == "arpack_defaults") { + lifecycle::deprecate_soft( + "1.5.0", + I("arpack_defaults"), + "arpack_defaults()", + details = c("So the function arpack_defaults(), not an object called arpack_defaults.") + ) + options <- arpack_defaults() + } + # Argument checks ensure_igraph(graph) if (!is.null(dist)) dist <- structure(as.double(dist), dim = dim(dist)) diff --git a/R/layout_drl.R b/R/layout_drl.R index c279ac13106..84bb912e2e7 100644 --- a/R/layout_drl.R +++ b/R/layout_drl.R @@ -95,9 +95,7 @@ layout_with_drl <- function(graph, use.seed = FALSE, use.seed <- as.logical(use.seed) seed <- as.matrix(seed) - options.tmp <- drl_defaults$default - options.tmp[names(options)] <- options - options <- options.tmp + options <- modify_list(drl_defaults$default, options) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight diff --git a/R/utils.R b/R/utils.R index b8b6920bb77..305e063dd33 100644 --- a/R/utils.R +++ b/R/utils.R @@ -97,3 +97,12 @@ chr <- as.character drop_null <- function(x) { x[!sapply(x, is.null)] } + +# from https://github.com/r-lib/pkgdown/blob/c354aa7e5ea1f9936692494c28c89e5bdd31fc68/R/utils.R#L109 +modify_list <- function(x, y) { + if (is.null(y)) { + return(x) + } + + utils::modifyList(x, y) +} diff --git a/R/zzz-deprecate.R b/R/zzz-deprecate.R index 3d4128a401f..54785c00651 100644 --- a/R/zzz-deprecate.R +++ b/R/zzz-deprecate.R @@ -305,8 +305,6 @@ deprecated("hrg.predict", predict_edges) #' @export hub.score deprecated("hub.score", hub_score) -#' @export igraph.arpack.default -deprecated("igraph.arpack.default", arpack_defaults) #' @export igraph.console deprecated("igraph.console", console) #' @export igraph.sample diff --git a/tools/stimulus/types-RR.yaml b/tools/stimulus/types-RR.yaml index 1752ebd4cd4..655f513be33 100644 --- a/tools/stimulus/types-RR.yaml +++ b/tools/stimulus/types-RR.yaml @@ -286,11 +286,11 @@ EDGESETLIST: ARPACKOPT: INCONV: - INOUT: '%I%.tmp <- arpack_defaults; %I%.tmp[ names(%I%) ] <- %I% ; %I% <- %I%.tmp' + INOUT: '%I% <- modify_list(arpack_defaults(), %I%)' DRL_OPTIONS: INCONV: - IN: '%I%.tmp <- drl_defaults$default; %I%.tmp [names(%I%)] <- %I%; %I% <- %I%.tmp' + IN: '%I% <- modify_list(drl_defaults$default, %I%)' STRVECTOR: {} @@ -424,7 +424,7 @@ PAGERANKOPT: if (%I1% == 0L) { %I% <- list(niter=1000, eps=0.001) } else if (%I1% == 1L) { - %I% <- arpack_defaults + %I% <- arpack_defaults() } else { %I% <- NULL } From fc921cf3bb52b63be12136355951ec2a3b3ec56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 16 May 2023 11:54:12 +0200 Subject: [PATCH 2/9] document() --- NAMESPACE | 1 - man/arpack.Rd | 10 ++-------- man/cluster_leading_eigen.Rd | 2 +- man/embed_adjacency_matrix.Rd | 2 +- man/embed_laplacian_matrix.Rd | 2 +- man/layout_with_mds.Rd | 2 +- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index d358f156fe3..0a5d6b24c38 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -484,7 +484,6 @@ export(hrg_tree) export(hub.score) export(hub_score) export(identical_graphs) -export(igraph.arpack.default) export(igraph.console) export(igraph.drl.coarsen) export(igraph.drl.coarsest) diff --git a/man/arpack.Rd b/man/arpack.Rd index b03d3d76471..604a431331a 100644 --- a/man/arpack.Rd +++ b/man/arpack.Rd @@ -1,24 +1,19 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/centrality.R -\docType{data} \name{arpack_defaults} \alias{arpack_defaults} \alias{arpack} \alias{arpack-options} -\alias{igraph.arpack.default} \alias{arpack.unpack.complex} \title{ARPACK eigenvector calculation} -\format{ -An object of class \code{list} of length 14. -} \usage{ -arpack_defaults +arpack_defaults() arpack( func, extra = NULL, sym = FALSE, - options = arpack_defaults, + options = arpack_defaults(), env = parent.frame(), complex = !sym ) @@ -223,5 +218,4 @@ Rich Lehoucq, Kristi Maschhoff, Danny Sorensen, Chao Yang for ARPACK, Gabor Csardi \email{csardi.gabor@gmail.com} for the R interface. } \concept{arpack} -\keyword{datasets} \keyword{graphs} diff --git a/man/cluster_leading_eigen.Rd b/man/cluster_leading_eigen.Rd index 9797582c908..a13c2b4f610 100644 --- a/man/cluster_leading_eigen.Rd +++ b/man/cluster_leading_eigen.Rd @@ -11,7 +11,7 @@ cluster_leading_eigen( steps = -1, weights = NULL, start = NULL, - options = arpack_defaults, + options = arpack_defaults(), callback = NULL, extra = NULL, env = parent.frame() diff --git a/man/embed_adjacency_matrix.Rd b/man/embed_adjacency_matrix.Rd index 4c5eceb7e29..0c1d752d4b0 100644 --- a/man/embed_adjacency_matrix.Rd +++ b/man/embed_adjacency_matrix.Rd @@ -42,7 +42,7 @@ graph. This vector is added to the diagonal of the adjacency matrix.} \item{options}{A named list containing the parameters for the SVD computation algorithm in ARPACK. By default, the list of values is assigned -the values given by \link{igraph.arpack.default}.} +the values given by \code{\link[=arpack_defaults]{arpack_defaults()}}.} } \value{ A list containing with entries: \item{X}{Estimated latent positions, diff --git a/man/embed_laplacian_matrix.Rd b/man/embed_laplacian_matrix.Rd index 15ff157d9d6..b2eb3b0ef39 100644 --- a/man/embed_laplacian_matrix.Rd +++ b/man/embed_laplacian_matrix.Rd @@ -59,7 +59,7 @@ returned instead of \eqn{X} and \eqn{Y}.} \item{options}{A named list containing the parameters for the SVD computation algorithm in ARPACK. By default, the list of values is assigned -the values given by \link{igraph.arpack.default}.} +the values given by \code{\link[=arpack_defaults]{arpack_defaults()}}.} } \value{ A list containing with entries: \item{X}{Estimated latent positions, diff --git a/man/layout_with_mds.Rd b/man/layout_with_mds.Rd index 2d00d42044d..d21994cdd8f 100644 --- a/man/layout_with_mds.Rd +++ b/man/layout_with_mds.Rd @@ -6,7 +6,7 @@ \alias{with_mds} \title{Graph layout by multidimensional scaling} \usage{ -layout_with_mds(graph, dist = NULL, dim = 2, options = arpack_defaults) +layout_with_mds(graph, dist = NULL, dim = 2, options = arpack_defaults()) with_mds(...) } From 903bde2716d054c23407beed8659dc2bcd0ec22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 16 May 2023 11:54:58 +0200 Subject: [PATCH 3/9] add here but the hack for revdeps is missing --- src/vendor/cigraph/interfaces/functions.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vendor/cigraph/interfaces/functions.yaml b/src/vendor/cigraph/interfaces/functions.yaml index 13581eb73c2..07df0cfd593 100644 --- a/src/vendor/cigraph/interfaces/functions.yaml +++ b/src/vendor/cigraph/interfaces/functions.yaml @@ -866,7 +866,7 @@ igraph_hub_score: PARAMS: |- GRAPH graph, OUT VERTEX_QTY vector, OUT REAL value, BOOLEAN scale=True, EDGEWEIGHTS weights=NULL, - INOUT ARPACKOPT options=arpack_defaults + INOUT ARPACKOPT options=arpack_defaults() DEPS: weights ON graph, vector ON graph igraph_authority_score: From 71b2b8c3774f2df99acf837479b6e0b33f2e3cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Thu, 29 Jun 2023 14:51:15 +0200 Subject: [PATCH 4/9] wrap auto funs as suggested by @krlmlr --- R/centrality.R | 80 ++++++++++++++++++++++++++++++++++++++--- man/eigen_centrality.Rd | 2 +- man/hub_score.Rd | 9 +++-- man/spectrum.Rd | 2 +- 4 files changed, 85 insertions(+), 8 deletions(-) diff --git a/R/centrality.R b/R/centrality.R index ee8b3c461b2..765b942b345 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -705,7 +705,24 @@ subgraph_centrality <- function(graph, diag = FALSE) { #' #' @family centrality #' @export -spectrum <- eigen_adjacency_impl +spectrum <- function(graph, algorithm=c("arpack", "auto", "lapack", "comp_auto", "comp_lapack", "comp_arpack"), which=list(), options=arpack_defaults()) { + eval_try <- rlang::eval_tidy(options) + options_value <- rlang::call_args(rlang::current_call())[["options"]] + if (is(eval_try, "function") && as.character(options_value) == "arpack_defaults") { + lifecycle::deprecate_soft( + "1.5.0", + I("arpack_defaults"), + "arpack_defaults()", + details = c("So the function arpack_defaults(), not an object called arpack_defaults.") + ) + options <- arpack_defaults() + } + + eigen_adjacency_impl(graph, + algorithm = algorithm, + which = which, + options = options) +} eigen_defaults <- function() { list( @@ -800,8 +817,30 @@ eigen_defaults <- function() { #' eigen_centrality(g) #' @family centrality #' @export -eigen_centrality <- eigenvector_centrality_impl +eigen_centrality <- function(graph, + directed = FALSE, + scale = TRUE, + weights = NULL, + options = arpack_defaults()) { + eval_try <- rlang::eval_tidy(options) + options_value <- rlang::call_args(rlang::current_call())[["options"]] + if (is(eval_try, "function") && as.character(options_value) == "arpack_defaults") { + lifecycle::deprecate_soft( + "1.5.0", + I("arpack_defaults"), + "arpack_defaults()", + details = c("So the function arpack_defaults(), not an object called arpack_defaults.") + ) + options <- arpack_defaults() + } + + eigenvector_centrality_impl(graph = graph, + directed = directed, + scale = scale, + weights = weights, + options = options) +} #' Strength or weighted vertex degree #' @@ -940,16 +979,49 @@ diversity <- diversity_impl #' hub_score(g2)$vector #' authority_score(g2)$vector #' @family centrality -hub_score <- hub_score_impl +hub_score <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) { + eval_try <- rlang::eval_tidy(options) + options_value <- rlang::call_args(rlang::current_call())[["options"]] + if (is(eval_try, "function") && as.character(options_value) == "arpack_defaults") { + lifecycle::deprecate_soft( + "1.5.0", + I("arpack_defaults"), + "arpack_defaults()", + details = c("So the function arpack_defaults(), not an object called arpack_defaults.") + ) + options <- arpack_defaults() + } + + hub_score_impl(graph = graph, + scale = scale, + weights = weights, + options = options) +} #' @rdname hub_score #' @aliases authority.score #' @param options A named list, to override some ARPACK options. See #' [arpack()] for details. #' @export -authority_score <- authority_score_impl +authority_score <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) { + eval_try <- rlang::eval_tidy(options) + options_value <- rlang::call_args(rlang::current_call())[["options"]] + if (is(eval_try, "function") && as.character(options_value) == "arpack_defaults") { + lifecycle::deprecate_soft( + "1.5.0", + I("arpack_defaults"), + "arpack_defaults()", + details = c("So the function arpack_defaults(), not an object called arpack_defaults.") + ) + options <- arpack_defaults() + } + authority_score_impl(graph = graph, + scale = scale, + weights = weights, + options = options) +} #' The Page Rank algorithm #' diff --git a/man/eigen_centrality.Rd b/man/eigen_centrality.Rd index f16f20fd1a5..ee4e8efa30b 100644 --- a/man/eigen_centrality.Rd +++ b/man/eigen_centrality.Rd @@ -10,7 +10,7 @@ eigen_centrality( directed = FALSE, scale = TRUE, weights = NULL, - options = arpack_defaults + options = arpack_defaults() ) } \arguments{ diff --git a/man/hub_score.Rd b/man/hub_score.Rd index 42e4883b955..133c5d677ee 100644 --- a/man/hub_score.Rd +++ b/man/hub_score.Rd @@ -7,9 +7,14 @@ \alias{authority.score} \title{Kleinberg's hub and authority centrality scores.} \usage{ -hub_score(graph, scale = TRUE, weights = NULL, options = arpack_defaults) +hub_score(graph, scale = TRUE, weights = NULL, options = arpack_defaults()) -authority_score(graph, scale = TRUE, weights = NULL, options = arpack_defaults) +authority_score( + graph, + scale = TRUE, + weights = NULL, + options = arpack_defaults() +) } \arguments{ \item{graph}{The input graph.} diff --git a/man/spectrum.Rd b/man/spectrum.Rd index 39de44cc803..244c1324372 100644 --- a/man/spectrum.Rd +++ b/man/spectrum.Rd @@ -10,7 +10,7 @@ spectrum( graph, algorithm = c("arpack", "auto", "lapack", "comp_auto", "comp_lapack", "comp_arpack"), which = list(), - options = arpack_defaults + options = arpack_defaults() ) } \arguments{ From 745b977f4a48e3e3c8eea0cc1e42552709cc90dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Fri, 10 Nov 2023 23:31:18 +0100 Subject: [PATCH 5/9] make -f Makefile-cigraph --- R/aaa-auto.R | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/R/aaa-auto.R b/R/aaa-auto.R index 005557f04dd..2318a610a87 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -371,7 +371,7 @@ personalized_pagerank_impl <- function(graph, algo=c("prpack", "arpack"), vids=V if (algo == 0L) { options <- list(niter=1000, eps=0.001) } else if (algo == 1L) { - options <- arpack_defaults + options <- arpack_defaults() } else { options <- NULL } @@ -562,7 +562,7 @@ eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, weigh } else { weights <- NULL } - options.tmp <- arpack_defaults; options.tmp[ names(options) ] <- options ; options <- options.tmp + options <- modify_list(arpack_defaults(), options) on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -585,7 +585,7 @@ hub_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defau } else { weights <- NULL } - options.tmp <- arpack_defaults; options.tmp[ names(options) ] <- options ; options <- options.tmp + options <- modify_list(arpack_defaults(), options) on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -608,7 +608,7 @@ authority_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack } else { weights <- NULL } - options.tmp <- arpack_defaults; options.tmp[ names(options) ] <- options ; options <- options.tmp + options <- modify_list(arpack_defaults(), options) on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -777,7 +777,7 @@ centralization_eigenvector_centrality_impl <- function(graph, directed=FALSE, sc ensure_igraph(graph) directed <- as.logical(directed) scale <- as.logical(scale) - options.tmp <- arpack_defaults; options.tmp[ names(options) ] <- options ; options <- options.tmp + options <- modify_list(arpack_defaults(), options) normalized <- as.logical(normalized) on.exit( .Call(R_igraph_finalizer) ) @@ -2028,7 +2028,7 @@ adjacency_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c(" which <- switch(igraph.match.arg(which), "lm"=0L, "la"=2L, "sa"=3L) scaled <- as.logical(scaled) cvec <- as.numeric(cvec) - options.tmp <- arpack_defaults; options.tmp[ names(options) ] <- options ; options <- options.tmp + options <- modify_list(arpack_defaults(), options) on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -2055,7 +2055,7 @@ laplacian_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c(" "da"=0L, "d-a"=0L, "idad"=1L, "i-dad"=1L, "dad"=2L, "oap"=3L) scaled <- as.logical(scaled) - options.tmp <- arpack_defaults; options.tmp[ names(options) ] <- options ; options <- options.tmp + options <- modify_list(arpack_defaults(), options) on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -2072,7 +2072,7 @@ eigen_adjacency_impl <- function(graph, algorithm=c("arpack", "auto", "lapack", "comp_arpack"=5) which.tmp <- eigen_defaults(); which.tmp[ names(which) ] <- which ; which <- which.tmp - options.tmp <- arpack_defaults; options.tmp[ names(options) ] <- options ; options <- options.tmp + options <- modify_list(arpack_defaults(), options) on.exit( .Call(R_igraph_finalizer) ) # Function call From 408ebada19cb4646ee9946696e401266c78052fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 13 Nov 2023 14:24:10 +0100 Subject: [PATCH 6/9] Change generated code, for now --- R/aaa-auto.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/aaa-auto.R b/R/aaa-auto.R index 2318a610a87..ee0fa728308 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -2013,7 +2013,7 @@ scg_norm_eps_impl <- function(V, groups, mtype=c("symmetric", "laplacian", "stoc res } -adjacency_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c("lm", "la", "sa"), scaled=TRUE, cvec=graph.strength(graph, weights=weights)/(vcount(graph)-1), options=igraph.arpack.default) { +adjacency_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c("lm", "la", "sa"), scaled=TRUE, cvec=graph.strength(graph, weights=weights)/(vcount(graph)-1), options=arpack_defaults()) { # Argument checks ensure_igraph(graph) no <- as.integer(no) @@ -2037,7 +2037,7 @@ adjacency_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c(" res } -laplacian_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c("lm", "la", "sa"), type=c("default", "D-A", "DAD", "I-DAD", "OAP"), scaled=TRUE, options=igraph.arpack.default) { +laplacian_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c("lm", "la", "sa"), type=c("default", "D-A", "DAD", "I-DAD", "OAP"), scaled=TRUE, options=arpack_defaults()) { # Argument checks ensure_igraph(graph) no <- as.integer(no) From 26d79374e9cdfb8b7925f9386fbae707adbdda76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 13 Nov 2023 14:24:23 +0100 Subject: [PATCH 7/9] Use standard evaluation --- R/centrality.R | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/R/centrality.R b/R/centrality.R index 765b942b345..3f8334f82b8 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -518,15 +518,13 @@ arpack <- function(func, extra = NULL, sym = FALSE, options = arpack_defaults(), env = parent.frame(), complex = !sym) { eval_try <- rlang::eval_tidy(options) - options_value <- rlang::call_args(rlang::current_call())[["options"]] - if (is(eval_try, "function") && as.character(options_value) == "arpack_defaults") { + if (is.function(options)) { lifecycle::deprecate_soft( - "1.5.0", - I("arpack_defaults"), - "arpack_defaults()", - details = c("So the function arpack_defaults(), not an object called arpack_defaults.") + "2.0.0", + "arpack_defaults(options = 'must be a list')", + details = c("`arpack_defaults()` is now a function, use `options = arpack_defaults()` instead of `options = arpack_defaults`.") ) - options <- arpack_defaults() + options <- options() } if (!is.list(options) || @@ -536,16 +534,18 @@ arpack <- function(func, extra = NULL, sym = FALSE, options = arpack_defaults(), if (any(names(options) == "")) { stop("all options must be named") } - if (any(!names(options) %in% names(arpack_defaults))) { + + defaults <- arpack_defaults() + if (any(!names(options) %in% names(defaults))) { stop( "unkown ARPACK option(s): ", - paste(setdiff(names(options), names(arpack_defaults)), + paste(setdiff(names(options), names(defaults)), collapse = ", " ) ) } - options <- modify_list(arpack_defaults(), options) + options <- modify_list(defaults, options) if (sym && complex) { complex <- FALSE From 756ebc80c3fc6a15928b1a9caa08b6047c02a59c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 13 Nov 2023 14:34:48 +0100 Subject: [PATCH 8/9] Bump source --- cigraph | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cigraph b/cigraph index 545e779c76c..58e14610c5a 160000 --- a/cigraph +++ b/cigraph @@ -1 +1 @@ -Subproject commit 545e779c76c54ba9d6ca5f6899c753201891519c +Subproject commit 58e14610c5af44cc1ca222090354a0b327af32f1 From 8759bf2ed5cecccd2ff4f086da42a97a243c0395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 13 Nov 2023 14:44:13 +0100 Subject: [PATCH 9/9] Fix defaults in Stimulus --- R/aaa-auto.R | 10 +++++----- man/centr_eigen.Rd | 2 +- man/embed_adjacency_matrix.Rd | 2 +- man/embed_laplacian_matrix.Rd | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/aaa-auto.R b/R/aaa-auto.R index ee0fa728308..bbf77516357 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -549,7 +549,7 @@ count_multiple_impl <- function(graph, eids=E(graph)) { res } -eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, weights=NULL, options=arpack_defaults) { +eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, weights=NULL, options=arpack_defaults()) { # Argument checks ensure_igraph(graph) directed <- as.logical(directed) @@ -573,7 +573,7 @@ eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, weigh res } -hub_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults) { +hub_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) { # Argument checks ensure_igraph(graph) scale <- as.logical(scale) @@ -596,7 +596,7 @@ hub_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defau res } -authority_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults) { +authority_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defaults()) { # Argument checks ensure_igraph(graph) scale <- as.logical(scale) @@ -772,7 +772,7 @@ centralization_closeness_tmax_impl <- function(graph=NULL, nodes=0, mode=c("out" res } -centralization_eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, options=arpack_defaults, normalized=TRUE) { +centralization_eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, options=arpack_defaults(), normalized=TRUE) { # Argument checks ensure_igraph(graph) directed <- as.logical(directed) @@ -2064,7 +2064,7 @@ laplacian_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c(" res } -eigen_adjacency_impl <- function(graph, algorithm=c("arpack", "auto", "lapack", "comp_auto", "comp_lapack", "comp_arpack"), which=list(), options=arpack_defaults) { +eigen_adjacency_impl <- function(graph, algorithm=c("arpack", "auto", "lapack", "comp_auto", "comp_lapack", "comp_arpack"), which=list(), options=arpack_defaults()) { # Argument checks ensure_igraph(graph) algorithm <- switch(igraph.match.arg(algorithm), "auto"=0, "lapack"=1, diff --git a/man/centr_eigen.Rd b/man/centr_eigen.Rd index 68f00f972d1..2c2a7dfdc3a 100644 --- a/man/centr_eigen.Rd +++ b/man/centr_eigen.Rd @@ -9,7 +9,7 @@ centr_eigen( graph, directed = FALSE, scale = TRUE, - options = arpack_defaults, + options = arpack_defaults(), normalized = TRUE ) } diff --git a/man/embed_adjacency_matrix.Rd b/man/embed_adjacency_matrix.Rd index 0c1d752d4b0..4657f50dfa2 100644 --- a/man/embed_adjacency_matrix.Rd +++ b/man/embed_adjacency_matrix.Rd @@ -11,7 +11,7 @@ embed_adjacency_matrix( which = c("lm", "la", "sa"), scaled = TRUE, cvec = graph.strength(graph, weights = weights)/(vcount(graph) - 1), - options = igraph.arpack.default + options = arpack_defaults() ) } \arguments{ diff --git a/man/embed_laplacian_matrix.Rd b/man/embed_laplacian_matrix.Rd index b2eb3b0ef39..1cd32d10e43 100644 --- a/man/embed_laplacian_matrix.Rd +++ b/man/embed_laplacian_matrix.Rd @@ -11,7 +11,7 @@ embed_laplacian_matrix( which = c("lm", "la", "sa"), type = c("default", "D-A", "DAD", "I-DAD", "OAP"), scaled = TRUE, - options = igraph.arpack.default + options = arpack_defaults() ) } \arguments{