From f812f042417ca1bb16be22bed5ed500b4de2a7ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 3 Apr 2023 13:00:16 +0200 Subject: [PATCH 1/5] refactor: kill igraph.arpack.default and arpack_defaults lists, add arpack_defaults() as a function! --- NAMESPACE | 1 - R/aaa-auto.R | 30 +++++++++++++++--------------- R/centrality.R | 23 ++++++++++++----------- R/community.R | 4 ++-- R/embedding.R | 4 ++-- R/layout.R | 4 ++-- R/zzz-deprecate.R | 2 -- man/arpack.Rd | 10 ++-------- man/centr_eigen.Rd | 2 +- man/cluster_leading_eigen.Rd | 2 +- man/eigen_centrality.Rd | 2 +- man/embed_adjacency_matrix.Rd | 4 ++-- man/embed_laplacian_matrix.Rd | 4 ++-- man/hub_score.Rd | 9 +++++++-- man/layout_with_mds.Rd | 2 +- man/spectrum.Rd | 2 +- tools/stimulus/types-RR.yaml | 4 ++-- 17 files changed, 53 insertions(+), 56 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 80077dbd720..5f0db0a4b38 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -489,7 +489,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/R/aaa-auto.R b/R/aaa-auto.R index 9636328d32f..ac0af2a273c 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 } @@ -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 if (!is_igraph(graph)) { stop("Not a graph object") } directed <- as.logical(directed) @@ -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.tmp <- arpack_defaults(); options.tmp[ names(options) ] <- options ; options <- options.tmp on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -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 if (!is_igraph(graph)) { stop("Not a graph object") } scale <- as.logical(scale) @@ -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.tmp <- arpack_defaults(); options.tmp[ names(options) ] <- options ; options <- options.tmp on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -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 if (!is_igraph(graph)) { stop("Not a graph object") } scale <- as.logical(scale) @@ -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.tmp <- arpack_defaults(); options.tmp[ names(options) ] <- options ; options <- options.tmp on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -772,12 +772,12 @@ 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 if (!is_igraph(graph)) { stop("Not a graph object") } directed <- as.logical(directed) scale <- as.logical(scale) - options.tmp <- arpack_defaults; options.tmp[ names(options) ] <- options ; options <- options.tmp + options.tmp <- arpack_defaults(); options.tmp[ names(options) ] <- options ; options <- options.tmp normalized <- as.logical(normalized) on.exit( .Call(R_igraph_finalizer) ) @@ -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 if (!is_igraph(graph)) { stop("Not a graph object") } no <- as.integer(no) @@ -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.tmp <- arpack_defaults(); options.tmp[ names(options) ] <- options ; options <- options.tmp on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -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 if (!is_igraph(graph)) { stop("Not a graph object") } no <- as.integer(no) @@ -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.tmp <- arpack_defaults(); options.tmp[ names(options) ] <- options ; options <- options.tmp on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -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 if (!is_igraph(graph)) { stop("Not a graph object") } algorithm <- switch(igraph.match.arg(algorithm), "auto"=0, "lapack"=1, @@ -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.tmp <- arpack_defaults(); options.tmp[ names(options) ] <- options ; options <- options.tmp on.exit( .Call(R_igraph_finalizer) ) # Function call diff --git a/R/centrality.R b/R/centrality.R index 7c7594a3ede..191b49d7579 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -305,11 +305,13 @@ estimate_closeness <- function(graph, vids = V(graph), mode = c("out", "in", "al #' @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 #' @@ -418,8 +420,7 @@ arpack_defaults <- list( #' re-orthogonalization.} } } Please see the ARPACK documentation for #' additional details. #' -#' @aliases arpack arpack-options igraph.arpack.default arpack.unpack.complex -#' arpack_defaults +#' @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} #' as the first argument, and it should return \eqn{Ax}, where \eqn{A} is the @@ -499,7 +500,7 @@ 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) { if (!is.list(options) || (is.null(names(options)) && length(options) != 0)) { @@ -508,16 +509,16 @@ 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))) { + if (any(!names(options) %in% names(arpack_defaults()))) { stop( "unkown ARPACK option(s): ", - paste(setdiff(names(options), names(arpack_defaults)), + paste(setdiff(names(options), names(arpack_defaults())), collapse = ", " ) ) } - options.tmp <- arpack_defaults + options.tmp <- arpack_defaults() options.tmp[names(options)] <- options options <- options.tmp diff --git a/R/community.R b/R/community.R index 0bfff1a684a..e7f7efd0d24 100644 --- a/R/community.R +++ b/R/community.R @@ -1669,7 +1669,7 @@ 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()) { # Argument checks @@ -1688,7 +1688,7 @@ cluster_leading_eigen <- function(graph, steps = -1, weights = NULL, if (!is.null(start)) { start <- as.numeric(start) - 1 } - options.tmp <- arpack_defaults + options.tmp <- arpack_defaults() options.tmp[names(options)] <- options options <- options.tmp 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 cea5e848eed..32d850b66b1 100644 --- a/R/layout.R +++ b/R/layout.R @@ -1514,7 +1514,7 @@ layout.lgl <- function(..., params = list()) { #' #' Warning: If the graph is symmetric to the exchange of two vertices (as is the #' case with leaves of a tree connecting to the same parent), classical -#' multidimensional scaling may assign the same coordinates to these vertices. +#' multidimensional scaling may assign the same coordinates to these vertices. #' #' This function generates the layout separately for each graph component and #' then merges them via [merge_coords()]. @@ -1544,7 +1544,7 @@ 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()) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") diff --git a/R/zzz-deprecate.R b/R/zzz-deprecate.R index 98ef6e532cc..f2f8b63b96b 100644 --- a/R/zzz-deprecate.R +++ b/R/zzz-deprecate.R @@ -317,8 +317,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/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/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/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/eigen_centrality.Rd b/man/eigen_centrality.Rd index 176fc399c86..c6ce4b9d27a 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/embed_adjacency_matrix.Rd b/man/embed_adjacency_matrix.Rd index 4c5eceb7e29..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{ @@ -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..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{ @@ -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/hub_score.Rd b/man/hub_score.Rd index 11a4bf7889b..a47357380e7 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/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(...) } diff --git a/man/spectrum.Rd b/man/spectrum.Rd index 9a6ee9e2c0d..cc3f1a4fee2 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{ diff --git a/tools/stimulus/types-RR.yaml b/tools/stimulus/types-RR.yaml index f56dc0047c6..5492b43fe90 100644 --- a/tools/stimulus/types-RR.yaml +++ b/tools/stimulus/types-RR.yaml @@ -286,7 +286,7 @@ EDGESETLIST: ARPACKOPT: INCONV: - INOUT: '%I%.tmp <- arpack_defaults; %I%.tmp[ names(%I%) ] <- %I% ; %I% <- %I%.tmp' + INOUT: '%I%.tmp <- arpack_defaults(); %I%.tmp[ names(%I%) ] <- %I% ; %I% <- %I%.tmp' DRL_OPTIONS: INCONV: @@ -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 31b33e225aa0c2d949a79ce507e8db02a298befe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 3 Apr 2023 13:13:47 +0200 Subject: [PATCH 2/5] use modifyList() for shorter code --- R/aaa-auto.R | 2 +- R/centrality.R | 4 +--- R/community.R | 4 +--- R/layout_drl.R | 4 +--- R/utils.R | 9 +++++++++ tools/stimulus/types-RR.yaml | 4 ++-- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/R/aaa-auto.R b/R/aaa-auto.R index ac0af2a273c..2c648fb806f 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -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 diff --git a/R/centrality.R b/R/centrality.R index 191b49d7579..264888fbfbc 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -518,9 +518,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 e7f7efd0d24..b0e21ee6cee 100644 --- a/R/community.R +++ b/R/community.R @@ -1688,9 +1688,7 @@ 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/layout_drl.R b/R/layout_drl.R index 5c4d19dd718..763e087c93b 100644 --- a/R/layout_drl.R +++ b/R/layout_drl.R @@ -102,9 +102,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/tools/stimulus/types-RR.yaml b/tools/stimulus/types-RR.yaml index 5492b43fe90..315ce0901e6 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: {} From ab5fb8882756b8839881e05485bf3f8c97372f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 11 Apr 2023 16:18:22 +0200 Subject: [PATCH 3/5] suggestion of a way to "deprecate" the old defaults --- R/centrality.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/R/centrality.R b/R/centrality.R index 264888fbfbc..e92877e20c5 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -502,6 +502,19 @@ arpack_defaults <- function() { #' @export 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 = "So a function, not an object." + ) + options <- arpack_defaults() + } + if (!is.list(options) || (is.null(names(options)) && length(options) != 0)) { stop("options must be a named list") From f31031e53b30d9734b1905ca07256eac39795299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 11 Apr 2023 16:51:01 +0200 Subject: [PATCH 4/5] oops --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 0dd4b29b970..a9f2c404e10 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,6 +10,7 @@ Depends: Imports: graphics, grDevices, + lifecycle, magrittr, Matrix, pkgconfig (>= 2.0.0), From c3a7e34b4abafa8bed6fc71c7efe5899f8fa1497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Thu, 20 Apr 2023 15:31:32 +0200 Subject: [PATCH 5/5] rephrase --- R/centrality.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/centrality.R b/R/centrality.R index e92877e20c5..e1f58c2a7bc 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -510,7 +510,7 @@ arpack <- function(func, extra = NULL, sym = FALSE, options = arpack_defaults(), "1.5.0", I("arpack_defaults"), "arpack_defaults()", - details = "So a function, not an object." + details = c("So the function arpack_defaults(), not an object called code arpack_defaults.") ) options <- arpack_defaults() }