From 5253256b714810b79480c96fea4387285062f360 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 18:14:17 +0000 Subject: [PATCH 1/5] refactor: Rename `nodes` to `n` in generators and `centr_*_tmax()` (#2788, #692) Vertex-count arguments unify on `n`: 11 game generators and their spec twins, the four `centr_*_tmax()` functions (`centr_degree_tmax()` and `centr_eigen_tmax()` newly gain their keyword-only migration on the way), and `graph_from_graphdb()`. Head positions keep working positionally; named `nodes =` callers are soft-deprecated via surviving sentinel formals or registry recovery. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01RTPj4qNv2FWui6etixZeuR --- R/centralization.R | 204 +++++++++++++--- R/foreign.R | 26 ++- R/games.R | 310 +++++++++++++++++++------ man/asymmetric.preference.game.Rd | 2 +- man/callaway.traits.game.Rd | 2 +- man/centr_betw_tmax.Rd | 14 +- man/centr_clo_tmax.Rd | 11 +- man/centr_degree_tmax.Rd | 14 +- man/centr_eigen_tmax.Rd | 14 +- man/centralization.betweenness.tmax.Rd | 5 +- man/centralization.closeness.tmax.Rd | 5 +- man/centralization.degree.tmax.Rd | 4 +- man/centralization.evcent.tmax.Rd | 5 +- man/establishment.game.Rd | 2 +- man/forest.fire.game.Rd | 2 +- man/graph.graphdb.Rd | 3 +- man/graph_from_graphdb.Rd | 6 +- man/grg.game.Rd | 2 +- man/preference.game.Rd | 2 +- man/sample_forestfire.Rd | 9 +- man/sample_grg.Rd | 8 +- man/sample_pref.Rd | 24 +- man/sample_traits_callaway.Rd | 24 +- tests/testthat/_snaps/foreign.md | 6 +- tests/testthat/_snaps/games.md | 18 ++ tests/testthat/test-centralization.R | 21 +- tests/testthat/test-foreign.R | 10 +- tests/testthat/test-games.R | 40 ++++ tools/migrations/centralization.R | 36 ++- tools/migrations/games.R | 55 +++-- tools/migrations/misc.R | 4 +- 31 files changed, 684 insertions(+), 204 deletions(-) diff --git a/R/centralization.R b/R/centralization.R index 5d9a3cd52c..94734e09f3 100644 --- a/R/centralization.R +++ b/R/centralization.R @@ -42,7 +42,7 @@ centralization.evcent.tmax <- function( ) centr_eigen_tmax( graph = graph, - nodes = nodes, + n = nodes, directed = directed, scale = scale ) @@ -98,7 +98,7 @@ centralization.degree.tmax <- function( "centralization.degree.tmax()", "centr_degree_tmax()" ) - centr_degree_tmax(graph = graph, nodes = nodes, mode = mode, loops = loops) + centr_degree_tmax(graph = graph, n = nodes, mode = mode, loops = loops) } # nocov end #' Centralize a graph according to the degrees of vertices @@ -152,7 +152,7 @@ centralization.closeness.tmax <- function( "centralization.closeness.tmax()", "centr_clo_tmax()" ) - centr_clo_tmax(graph = graph, nodes = nodes, mode = mode) + centr_clo_tmax(graph = graph, n = nodes, mode = mode) } # nocov end #' Centralize a graph according to the closeness of vertices @@ -200,7 +200,7 @@ centralization.betweenness.tmax <- function( "centralization.betweenness.tmax()", "centr_betw_tmax()" ) - centr_betw_tmax(graph = graph, nodes = nodes, directed = directed) + centr_betw_tmax(graph = graph, n = nodes, directed = directed) } # nocov end #' Centralize a graph according to the betweenness of vertices @@ -463,8 +463,10 @@ centr_degree <- function( #' #' See [centralize()] for a summary of graph centralization. #' -#' @param graph The input graph. It can also be `NULL` if `nodes` is given. -#' @param nodes The number of vertices. This is ignored if the graph is given. +#' @param graph The input graph. It can also be `NULL` if `n` is given. +#' @param n The number of vertices. This is ignored if the graph is given. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. +#' @inheritParams rlang::args_dots_empty #' @param mode This is the same as the `mode` argument of `degree()`. Ignored #' if `graph` is given and the graph is undirected. #' @inheritParams centr_degree @@ -483,10 +485,64 @@ centr_degree <- function( #' centr_degree(g, normalized = TRUE)$centralization centr_degree_tmax <- function( graph = NULL, - nodes = 0, + n = 0, + ..., mode = c("all", "out", "in", "total"), - loops + loops, + nodes = deprecated() ) { + # BEGIN GENERATED ARG_HANDLE: centr_degree_tmax, do not edit, see tools/generate-migrations.R + # fmt: skip + if (...length() > 0L) { + # Pre-3.0.0 signature: centr_degree_tmax(graph, nodes, mode, loops) + .old_signature <- function(mode, loops, ...) { + if (...length() > 0L) { + .arg_extra <- base::names(base::substitute(...())) + .arg_extra <- .arg_extra[base::nzchar(.arg_extra)] + if (base::length(.arg_extra) == 0L) cli::cli_abort("Too many arguments passed to {.fn centr_degree_tmax}.", call = base::parent.frame()) + cli::cli_abort(base::c("Unexpected argument passed to {.fn centr_degree_tmax}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) + } + base::c( + if (!base::missing(mode)) base::list(mode = mode), + if (!base::missing(loops)) base::list(loops = loops) + ) + } + .arg_handle <- .old_signature(...) + if (base::length(.arg_handle) > 0L) { + .arg_names <- base::names(.arg_handle) + .arg_conflict <- base::intersect(.arg_names, base::c( + if (!base::missing(mode)) "mode", + if (!base::missing(loops)) "loops" + )) + if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn centr_degree_tmax} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) + base::list2env(.arg_handle, base::environment()) + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `centr_degree_tmax()` with positional or abbreviated arguments"), + details = base::c( + i = base::paste0("Detected call: centr_degree_tmax(", base::paste(base::c("graph", "n", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: centr_degree_tmax(", base::paste(base::c("graph", "n", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + ) + ) + } + } + # END GENERATED ARG_HANDLE + + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn centr_degree_tmax} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "centr_degree_tmax(nodes = )", + "centr_degree_tmax(n = )" + ) + n <- nodes + } + if (!lifecycle::is_present(loops)) { lifecycle::deprecate_stop( when = "2.0.0", @@ -498,14 +554,14 @@ centr_degree_tmax <- function( # Argument checks ensure_igraph(graph, optional = TRUE) - nodes <- as.numeric(nodes) + n <- as.numeric(n) loops <- as.logical(loops) # Function call res <- centralization_degree_tmax_impl( graph = graph, - nodes = nodes, + nodes = n, mode = mode, loops = loops ) @@ -615,9 +671,10 @@ centr_betw <- function( #' See [centralize()] for a summary of graph centralization. #' #' @param graph The input graph. It can also be `NULL` if -#' `nodes` and `directed` are both given. -#' @param nodes The number of vertices. This is ignored if the graph is +#' `n` and `directed` are both given. +#' @param n The number of vertices. This is ignored if the graph is #' given. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. #' @inheritParams rlang::args_dots_empty #' @param directed Logical, whether to use directed shortest paths #' for calculating betweenness. Ignored if an undirected graph was @@ -638,9 +695,10 @@ centr_betw <- function( #' centr_betw(g, normalized = TRUE)$centralization centr_betw_tmax <- function( graph = NULL, - nodes = 0, + n = 0, ..., - directed = TRUE + directed = TRUE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: centr_betw_tmax, do not edit, see tools/generate-migrations.R # fmt: skip @@ -669,17 +727,32 @@ centr_betw_tmax <- function( "3.0.0", what = base::I("Calling `centr_betw_tmax()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: centr_betw_tmax(", base::paste(base::c("graph", "nodes", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: centr_betw_tmax(", base::paste(base::c("graph", "nodes", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: centr_betw_tmax(", base::paste(base::c("graph", "n", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: centr_betw_tmax(", base::paste(base::c("graph", "n", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn centr_betw_tmax} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "centr_betw_tmax(nodes = )", + "centr_betw_tmax(n = )" + ) + n <- nodes + } + centralization_betweenness_tmax_impl( graph = graph, - nodes = nodes, + nodes = n, directed = directed ) } @@ -776,9 +849,10 @@ centr_clo <- function( #' See [centralize()] for a summary of graph centralization. #' #' @param graph The input graph. It can also be `NULL` if -#' `nodes` is given. -#' @param nodes The number of vertices. This is ignored if the graph is +#' `n` is given. +#' @param n The number of vertices. This is ignored if the graph is #' given. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. #' @inheritParams rlang::args_dots_empty #' @param mode This is the same as the `mode` argument of #' `closeness()`. Ignored if an undirected graph is given. @@ -798,9 +872,10 @@ centr_clo <- function( #' centr_clo(g, normalized = TRUE)$centralization centr_clo_tmax <- function( graph = NULL, - nodes = 0, + n = 0, ..., - mode = c("out", "in", "all", "total") + mode = c("out", "in", "all", "total"), + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: centr_clo_tmax, do not edit, see tools/generate-migrations.R # fmt: skip @@ -829,17 +904,32 @@ centr_clo_tmax <- function( "3.0.0", what = base::I("Calling `centr_clo_tmax()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: centr_clo_tmax(", base::paste(base::c("graph", "nodes", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: centr_clo_tmax(", base::paste(base::c("graph", "nodes", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: centr_clo_tmax(", base::paste(base::c("graph", "n", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: centr_clo_tmax(", base::paste(base::c("graph", "n", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn centr_clo_tmax} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "centr_clo_tmax(nodes = )", + "centr_clo_tmax(n = )" + ) + n <- nodes + } + centralization_closeness_tmax_impl( graph = graph, - nodes = nodes, + nodes = n, mode = mode ) } @@ -923,9 +1013,11 @@ centr_eigen <- function( #' See [centralize()] for a summary of graph centralization. #' #' @param graph The input graph. It can also be `NULL`, if -#' `nodes` is given. -#' @param nodes The number of vertices. This is ignored if the graph is +#' `n` is given. +#' @param n The number of vertices. This is ignored if the graph is #' given. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. +#' @inheritParams rlang::args_dots_empty #' @param directed Logical, whether to consider edge directions #' during the calculation. Ignored in undirected graphs. #' @param scale `r lifecycle::badge("deprecated")` Ignored. Computing @@ -946,10 +1038,64 @@ centr_eigen <- function( #' centr_eigen(g, normalized = TRUE)$centralization centr_eigen_tmax <- function( graph = NULL, - nodes = 0, + n = 0, + ..., directed = FALSE, - scale = deprecated() + scale = deprecated(), + nodes = deprecated() ) { + # BEGIN GENERATED ARG_HANDLE: centr_eigen_tmax, do not edit, see tools/generate-migrations.R + # fmt: skip + if (...length() > 0L) { + # Pre-3.0.0 signature: centr_eigen_tmax(graph, nodes, directed, scale) + .old_signature <- function(directed, scale, ...) { + if (...length() > 0L) { + .arg_extra <- base::names(base::substitute(...())) + .arg_extra <- .arg_extra[base::nzchar(.arg_extra)] + if (base::length(.arg_extra) == 0L) cli::cli_abort("Too many arguments passed to {.fn centr_eigen_tmax}.", call = base::parent.frame()) + cli::cli_abort(base::c("Unexpected argument passed to {.fn centr_eigen_tmax}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) + } + base::c( + if (!base::missing(directed)) base::list(directed = directed), + if (!base::missing(scale)) base::list(scale = scale) + ) + } + .arg_handle <- .old_signature(...) + if (base::length(.arg_handle) > 0L) { + .arg_names <- base::names(.arg_handle) + .arg_conflict <- base::intersect(.arg_names, base::c( + if (!base::missing(directed)) "directed", + if (!base::missing(scale)) "scale" + )) + if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn centr_eigen_tmax} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) + base::list2env(.arg_handle, base::environment()) + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `centr_eigen_tmax()` with positional or abbreviated arguments"), + details = base::c( + i = base::paste0("Detected call: centr_eigen_tmax(", base::paste(base::c("graph", "n", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: centr_eigen_tmax(", base::paste(base::c("graph", "n", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + ) + ) + } + } + # END GENERATED ARG_HANDLE + + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn centr_eigen_tmax} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "centr_eigen_tmax(nodes = )", + "centr_eigen_tmax(n = )" + ) + n <- nodes + } + if (lifecycle::is_present(scale)) { lifecycle::deprecate_warn( "2.2.0", @@ -961,7 +1107,7 @@ centr_eigen_tmax <- function( centralization_eigenvector_centrality_tmax_impl( graph = graph, - nodes = nodes, + nodes = n, directed = directed, scale = TRUE ) diff --git a/R/foreign.R b/R/foreign.R index d0768024e4..52b7f517fe 100644 --- a/R/foreign.R +++ b/R/foreign.R @@ -67,6 +67,8 @@ read.graph <- function( #' `graph.graphdb()` was renamed to [graph_from_graphdb()] to create a more #' consistent API. #' @inheritParams graph_from_graphdb +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` in +#' [graph_from_graphdb()] instead. #' @keywords internal #' @export graph.graphdb <- function( @@ -86,7 +88,7 @@ graph.graphdb <- function( url = url, prefix = prefix, type = type, - nodes = nodes, + n = nodes, pair = pair, which = which, base = base, @@ -785,7 +787,7 @@ write.graph.dot <- function(graph, file) { #' [read_graph()] with the proper arguments to read the file. #' #' If `url` is `NULL`, and this is the default, then the filename is -#' assembled from the `base`, `prefix`, `type`, `nodes`, +#' assembled from the `base`, `prefix`, `type`, `n`, #' `pair` and `which` arguments. #' #' Unfortunately the original graph database homepage is now defunct, but see @@ -804,7 +806,7 @@ write.graph.dot <- function(graph, file) { #' `m3Dr4`, `m3Dr6`, `m4D`, `m4Dr2`, `m4Dr4`, #' `m4Dr6`, `b03`, `b03m`, `b06`, `b06m`, `b09`, #' `b09m`. -#' @param nodes The number of vertices in the graph. +#' @param n The number of vertices in the graph. #' @param pair Specifies which graph of the pair to read. Possible values: #' `A` and `B`. #' @param which Gives the number of the graph to read. For every graph type @@ -829,7 +831,7 @@ graph_from_graphdb <- function( ..., prefix = "iso", type = "r001", - nodes = NULL, + n = NULL, pair = "A", which = 0, base = "https://github.com/igraph/graphsdb/raw/refs/heads/main", @@ -852,7 +854,7 @@ graph_from_graphdb <- function( base::c( if (!base::missing(prefix)) base::list(prefix = prefix), if (!base::missing(type)) base::list(type = type), - if (!base::missing(nodes)) base::list(nodes = nodes), + if (!base::missing(nodes)) base::list(n = nodes), if (!base::missing(pair)) base::list(pair = pair), if (!base::missing(which)) base::list(which = which), if (!base::missing(base)) base::list(base = base), @@ -866,7 +868,7 @@ graph_from_graphdb <- function( .arg_conflict <- base::intersect(.arg_names, base::c( if (!base::missing(prefix)) "prefix", if (!base::missing(type)) "type", - if (!base::missing(nodes)) "nodes", + if (!base::missing(n)) "n", if (!base::missing(pair)) "pair", if (!base::missing(which)) "which", if (!base::missing(base)) "base", @@ -879,7 +881,7 @@ graph_from_graphdb <- function( "3.0.0", what = base::I("Calling `graph_from_graphdb()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: graph_from_graphdb(", base::paste(base::c("url", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: graph_from_graphdb(", base::paste(base::c("url", base::c(prefix = "prefix", type = "type", n = "nodes", pair = "pair", which = "which", base = "base", compressed = "compressed", directed = "directed")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: graph_from_graphdb(", base::paste(base::c("url", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -887,8 +889,8 @@ graph_from_graphdb <- function( } # END GENERATED ARG_HANDLE - if (is.null(nodes) && is.null(url)) { - cli::cli_abort("Either {.arg nodes}' or `{.arg url}' must be non-null.") + if (is.null(n) && is.null(url)) { + cli::cli_abort("Either {.arg n}' or `{.arg url}' must be non-null.") } if (is.null(url)) { @@ -917,9 +919,9 @@ graph_from_graphdb <- function( "b09", "b09m" ) - sizecode <- if (nodes <= 100) { + sizecode <- if (n <= 100) { "s" - } else if (nodes < 2000) { + } else if (n < 2000) { "m" } else { "l" @@ -958,7 +960,7 @@ graph_from_graphdb <- function( type, "_", sizecode, - nodes, + n, ".", pair, formatC(which, width = 2, flag = "0"), diff --git a/R/games.R b/R/games.R index c61ca99b11..89ee687859 100644 --- a/R/games.R +++ b/R/games.R @@ -150,7 +150,7 @@ preference.game <- function( # nocov start lifecycle::deprecate_warn("2.0.0", "preference.game()", "sample_pref()") sample_pref( - nodes = nodes, + n = nodes, types = types, type.dist = type.dist, fixed.sizes = fixed.sizes, @@ -252,7 +252,7 @@ interconnected.islands.game <- function( grg.game <- function(nodes, radius, torus = FALSE, coords = FALSE) { # nocov start lifecycle::deprecate_warn("2.0.0", "grg.game()", "sample_grg()") - sample_grg(nodes = nodes, radius = radius, torus = torus, coords = coords) + sample_grg(n = nodes, radius = radius, torus = torus, coords = coords) } # nocov end #' Growing random graph generation @@ -299,7 +299,7 @@ forest.fire.game <- function( "sample_forestfire()" ) sample_forestfire( - nodes = nodes, + n = nodes, fw.prob = fw.prob, bw.factor = bw.factor, ambs = ambs, @@ -328,7 +328,7 @@ establishment.game <- function( # nocov start lifecycle::deprecate_warn("2.0.0", "establishment.game()", "sample_traits()") sample_traits( - nodes = nodes, + n = nodes, types = types, k = k, type.dist = type.dist, @@ -470,7 +470,7 @@ callaway.traits.game <- function( "sample_traits_callaway()" ) sample_traits_callaway( - nodes = nodes, + n = nodes, types = types, edge.per.step = edge.per.step, type.dist = type.dist, @@ -605,7 +605,7 @@ asymmetric.preference.game <- function( "sample_asym_pref()" ) sample_asym_pref( - nodes = nodes, + n = nodes, types = types, type.dist.matrix = type.dist.matrix, pref.matrix = pref.matrix, @@ -2201,7 +2201,8 @@ pa_age <- function( #' depends on the types of the vertices involved and is taken from #' `pref.matrix`. #' -#' @param nodes The number of vertices in the graph. +#' @param n The number of vertices in the graph. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. #' @param types The number of different vertex types. #' @inheritParams rlang::args_dots_empty #' @param edge.per.step The number of edges to add to the graph per time step. @@ -2223,13 +2224,14 @@ pa_age <- function( #' g1 <- sample_traits_callaway(1000, 2, pref.matrix = matrix(c(1, 0, 0, 1), ncol = 2)) #' g2 <- sample_traits(1000, 2, k = 2, pref.matrix = matrix(c(1, 0, 0, 1), ncol = 2)) sample_traits_callaway <- function( - nodes, + n, types, ..., edge.per.step = 1, type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: sample_traits_callaway, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2266,14 +2268,29 @@ sample_traits_callaway <- function( "3.0.0", what = base::I("Calling `sample_traits_callaway()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: sample_traits_callaway(", base::paste(base::c("nodes", "types", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: sample_traits_callaway(", base::paste(base::c("nodes", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: sample_traits_callaway(", base::paste(base::c("n", "types", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_traits_callaway(", base::paste(base::c("n", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn sample_traits_callaway} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "sample_traits_callaway(nodes = )", + "sample_traits_callaway(n = )" + ) + n <- nodes + } + if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2282,7 +2299,7 @@ sample_traits_callaway <- function( } res <- callaway_traits_game_impl( - nodes = nodes, + nodes = n, types = types, edges_per_step = edge.per.step, type_dist = type.dist, @@ -2307,13 +2324,14 @@ sample_traits_callaway <- function( #' @inheritParams rlang::args_dots_empty #' @export traits_callaway <- function( - nodes, + n, types, ..., edge.per.step = 1, type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: traits_callaway, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2350,14 +2368,29 @@ traits_callaway <- function( "3.0.0", what = base::I("Calling `traits_callaway()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: traits_callaway(", base::paste(base::c("nodes", "types", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: traits_callaway(", base::paste(base::c("nodes", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: traits_callaway(", base::paste(base::c("n", "types", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: traits_callaway(", base::paste(base::c("n", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn traits_callaway} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "traits_callaway(nodes = )", + "traits_callaway(n = )" + ) + n <- nodes + } + if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2367,7 +2400,7 @@ traits_callaway <- function( constructor_spec( sample_traits_callaway, - nodes, + n, types, edge.per.step = edge.per.step, type.dist = type.dist, @@ -2380,13 +2413,14 @@ traits_callaway <- function( #' @inheritParams rlang::args_dots_empty #' @export sample_traits <- function( - nodes, + n, types, k = 1, ..., type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: sample_traits, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2421,14 +2455,29 @@ sample_traits <- function( "3.0.0", what = base::I("Calling `sample_traits()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: sample_traits(", base::paste(base::c("nodes", "types", "k", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: sample_traits(", base::paste(base::c("nodes", "types", "k", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: sample_traits(", base::paste(base::c("n", "types", "k", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_traits(", base::paste(base::c("n", "types", "k", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn sample_traits} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "sample_traits(nodes = )", + "sample_traits(n = )" + ) + n <- nodes + } + if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2437,7 +2486,7 @@ sample_traits <- function( } res <- establishment_game_impl( - nodes = nodes, + nodes = n, types = types, k = k, type_dist = type.dist, @@ -2458,13 +2507,14 @@ sample_traits <- function( #' @inheritParams rlang::args_dots_empty #' @export traits <- function( - nodes, + n, types, k = 1, ..., type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: traits, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2499,14 +2549,29 @@ traits <- function( "3.0.0", what = base::I("Calling `traits()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: traits(", base::paste(base::c("nodes", "types", "k", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: traits(", base::paste(base::c("nodes", "types", "k", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: traits(", base::paste(base::c("n", "types", "k", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: traits(", base::paste(base::c("n", "types", "k", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn traits} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "traits(nodes = )", + "traits(n = )" + ) + n <- nodes + } + if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2516,7 +2581,7 @@ traits <- function( constructor_spec( sample_traits, - nodes, + n, types, k = k, type.dist = type.dist, @@ -2538,7 +2603,8 @@ traits <- function( #' Euclidean norm than a given radius. If the `torus` argument is #' `TRUE` then a unit area torus is used instead of a square. #' -#' @param nodes The number of vertices in the graph. +#' @param n The number of vertices in the graph. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. #' @param radius The radius within which the vertices will be connected by an #' edge. #' @inheritParams rlang::args_dots_empty @@ -2558,11 +2624,12 @@ traits <- function( #' g2 <- sample_grg(1000, 0.05, torus = TRUE) #' sample_grg <- function( - nodes, + n, radius, ..., torus = FALSE, - coords = FALSE + coords = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: sample_grg, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2593,18 +2660,33 @@ sample_grg <- function( "3.0.0", what = base::I("Calling `sample_grg()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: sample_grg(", base::paste(base::c("nodes", "radius", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: sample_grg(", base::paste(base::c("nodes", "radius", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: sample_grg(", base::paste(base::c("n", "radius", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_grg(", base::paste(base::c("n", "radius", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn sample_grg} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "sample_grg(nodes = )", + "sample_grg(n = )" + ) + n <- nodes + } + on.exit(.Call(Rx_igraph_finalizer)) res <- .Call( Rx_igraph_grg_game, - as.double(nodes), + as.double(n), as.double(radius), as.logical(torus), as.logical(coords) @@ -2625,11 +2707,12 @@ sample_grg <- function( #' @inheritParams rlang::args_dots_empty #' @export grg <- function( - nodes, + n, radius, ..., torus = FALSE, - coords = FALSE + coords = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: grg, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2660,17 +2743,32 @@ grg <- function( "3.0.0", what = base::I("Calling `grg()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: grg(", base::paste(base::c("nodes", "radius", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: grg(", base::paste(base::c("nodes", "radius", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: grg(", base::paste(base::c("n", "radius", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: grg(", base::paste(base::c("n", "radius", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn grg} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "grg(nodes = )", + "grg(n = )" + ) + n <- nodes + } + constructor_spec( sample_grg, - nodes = nodes, + n = n, radius = radius, torus = torus, coords = coords @@ -2701,7 +2799,8 @@ grg <- function( #' `type` vertex attribute for `sample_pref()` and from the #' `intype` and `outtype` vertex attribute for `sample_asym_pref()`. #' -#' @param nodes The number of vertices in the graphs. +#' @param n The number of vertices in the graphs. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. #' @param types The number of different vertex types. #' @inheritParams rlang::args_dots_empty #' @param type.dist The distribution of the vertex types, a numeric vector of @@ -2741,14 +2840,15 @@ grg <- function( #' tkplot(g, layout = layout_in_circle) #' sample_pref <- function( - nodes, + n, types, ..., type.dist = NULL, fixed.sizes = FALSE, pref.matrix = NULL, directed = FALSE, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: sample_pref, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2787,14 +2887,29 @@ sample_pref <- function( "3.0.0", what = base::I("Calling `sample_pref()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: sample_pref(", base::paste(base::c("nodes", "types", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: sample_pref(", base::paste(base::c("nodes", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: sample_pref(", base::paste(base::c("n", "types", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_pref(", base::paste(base::c("n", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn sample_pref} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "sample_pref(nodes = )", + "sample_pref(n = )" + ) + n <- nodes + } + if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2810,7 +2925,7 @@ sample_pref <- function( } res <- preference_game_impl( - nodes = nodes, + nodes = n, types = types, type_dist = type.dist, fixed_sizes = fixed.sizes, @@ -2834,14 +2949,15 @@ sample_pref <- function( #' @inheritParams rlang::args_dots_empty #' @export pref <- function( - nodes, + n, types, ..., type.dist = NULL, fixed.sizes = FALSE, pref.matrix = NULL, directed = FALSE, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: pref, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2880,14 +2996,29 @@ pref <- function( "3.0.0", what = base::I("Calling `pref()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: pref(", base::paste(base::c("nodes", "types", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: pref(", base::paste(base::c("nodes", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: pref(", base::paste(base::c("n", "types", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: pref(", base::paste(base::c("n", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn pref} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "pref(nodes = )", + "pref(n = )" + ) + n <- nodes + } + if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2897,7 +3028,7 @@ pref <- function( constructor_spec( sample_pref, - nodes, + n, types, type.dist = type.dist, fixed.sizes = fixed.sizes, @@ -2911,12 +3042,13 @@ pref <- function( #' @inheritParams rlang::args_dots_empty #' @export sample_asym_pref <- function( - nodes, + n, types, ..., type.dist.matrix = NULL, pref.matrix = NULL, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: sample_asym_pref, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2951,14 +3083,29 @@ sample_asym_pref <- function( "3.0.0", what = base::I("Calling `sample_asym_pref()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: sample_asym_pref(", base::paste(base::c("nodes", "types", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: sample_asym_pref(", base::paste(base::c("nodes", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: sample_asym_pref(", base::paste(base::c("n", "types", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_asym_pref(", base::paste(base::c("n", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn sample_asym_pref} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "sample_asym_pref(nodes = )", + "sample_asym_pref(n = )" + ) + n <- nodes + } + if (is.null(type.dist.matrix)) { type.dist.matrix <- matrix(1, types, types) } @@ -2980,7 +3127,7 @@ sample_asym_pref <- function( } res <- asymmetric_preference_game_impl( - nodes = nodes, + nodes = n, out_types = types, in_types = types, type_dist_matrix = type.dist.matrix, @@ -3004,12 +3151,13 @@ sample_asym_pref <- function( #' @inheritParams rlang::args_dots_empty #' @export asym_pref <- function( - nodes, + n, types, ..., type.dist.matrix = NULL, pref.matrix = NULL, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: asym_pref, do not edit, see tools/generate-migrations.R # fmt: skip @@ -3044,14 +3192,29 @@ asym_pref <- function( "3.0.0", what = base::I("Calling `asym_pref()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: asym_pref(", base::paste(base::c("nodes", "types", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: asym_pref(", base::paste(base::c("nodes", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: asym_pref(", base::paste(base::c("n", "types", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: asym_pref(", base::paste(base::c("n", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn asym_pref} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "asym_pref(nodes = )", + "asym_pref(n = )" + ) + n <- nodes + } + if (is.null(type.dist.matrix)) { type.dist.matrix <- matrix(1, types, types) } @@ -3061,7 +3224,7 @@ asym_pref <- function( constructor_spec( sample_asym_pref, - nodes, + n, types, type.dist.matrix = type.dist.matrix, pref.matrix = pref.matrix, @@ -4955,7 +5118,8 @@ sample_fitness_pl <- function( #' available then we cite all of them. \item The same procedure is applied to #' all the newly cited vertices. } #' -#' @param nodes The number of vertices in the graph. +#' @param n The number of vertices in the graph. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. #' @param fw.prob The forward burning probability, see details below. #' @inheritParams rlang::args_dots_empty #' @param bw.factor The backward burning ratio. The backward burning @@ -4992,12 +5156,13 @@ sample_fitness_pl <- function( #' plot(seq(along.with = dd1) - 1, dd1, log = "xy") #' points(seq(along.with = dd2) - 1, dd2, col = 2, pch = 2) sample_forestfire <- function( - nodes, + n, fw.prob, ..., bw.factor = 1, ambs = 1, - directed = TRUE + directed = TRUE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: sample_forestfire, do not edit, see tools/generate-migrations.R # fmt: skip @@ -5030,16 +5195,31 @@ sample_forestfire <- function( "3.0.0", what = base::I("Calling `sample_forestfire()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: sample_forestfire(", base::paste(base::c("nodes", "fw.prob", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: sample_forestfire(", base::paste(base::c("nodes", "fw.prob", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: sample_forestfire(", base::paste(base::c("n", "fw.prob", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_forestfire(", base::paste(base::c("n", "fw.prob", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn sample_forestfire} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "sample_forestfire(nodes = )", + "sample_forestfire(n = )" + ) + n <- nodes + } + res <- forest_fire_game_impl( - nodes = nodes, + nodes = n, fw_prob = fw.prob, bw_factor = bw.factor, ambs = ambs, diff --git a/man/asymmetric.preference.game.Rd b/man/asymmetric.preference.game.Rd index a25892561c..59208d16a4 100644 --- a/man/asymmetric.preference.game.Rd +++ b/man/asymmetric.preference.game.Rd @@ -13,7 +13,7 @@ asymmetric.preference.game( ) } \arguments{ -\item{nodes}{The number of vertices in the graphs.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{types}{The number of different vertex types.} diff --git a/man/callaway.traits.game.Rd b/man/callaway.traits.game.Rd index 487c885599..06b6e30f60 100644 --- a/man/callaway.traits.game.Rd +++ b/man/callaway.traits.game.Rd @@ -14,7 +14,7 @@ callaway.traits.game( ) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{types}{The number of different vertex types.} diff --git a/man/centr_betw_tmax.Rd b/man/centr_betw_tmax.Rd index 6da3968daf..0b6e02683d 100644 --- a/man/centr_betw_tmax.Rd +++ b/man/centr_betw_tmax.Rd @@ -4,13 +4,19 @@ \alias{centr_betw_tmax} \title{Theoretical maximum for betweenness centralization} \usage{ -centr_betw_tmax(graph = NULL, nodes = 0, ..., directed = TRUE) +centr_betw_tmax( + graph = NULL, + n = 0, + ..., + directed = TRUE, + nodes = deprecated() +) } \arguments{ \item{graph}{The input graph. It can also be \code{NULL} if -\code{nodes} and \code{directed} are both given.} +\code{n} and \code{directed} are both given.} -\item{nodes}{The number of vertices. This is ignored if the graph is +\item{n}{The number of vertices. This is ignored if the graph is given.} \item{...}{These dots are for future extensions and must be empty.} @@ -18,6 +24,8 @@ given.} \item{directed}{Logical, whether to use directed shortest paths for calculating betweenness. Ignored if an undirected graph was given.} + +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} } \value{ Real scalar, the theoretical maximum (unnormalized) graph diff --git a/man/centr_clo_tmax.Rd b/man/centr_clo_tmax.Rd index 93fbe09cde..c7c5b500a1 100644 --- a/man/centr_clo_tmax.Rd +++ b/man/centr_clo_tmax.Rd @@ -6,22 +6,25 @@ \usage{ centr_clo_tmax( graph = NULL, - nodes = 0, + n = 0, ..., - mode = c("out", "in", "all", "total") + mode = c("out", "in", "all", "total"), + nodes = deprecated() ) } \arguments{ \item{graph}{The input graph. It can also be \code{NULL} if -\code{nodes} is given.} +\code{n} is given.} -\item{nodes}{The number of vertices. This is ignored if the graph is +\item{n}{The number of vertices. This is ignored if the graph is given.} \item{...}{These dots are for future extensions and must be empty.} \item{mode}{This is the same as the \code{mode} argument of \code{closeness()}. Ignored if an undirected graph is given.} + +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} } \value{ Real scalar, the theoretical maximum (unnormalized) graph diff --git a/man/centr_degree_tmax.Rd b/man/centr_degree_tmax.Rd index 7a6f8cae48..a5a22e4c86 100644 --- a/man/centr_degree_tmax.Rd +++ b/man/centr_degree_tmax.Rd @@ -6,21 +6,27 @@ \usage{ centr_degree_tmax( graph = NULL, - nodes = 0, + n = 0, + ..., mode = c("all", "out", "in", "total"), - loops + loops, + nodes = deprecated() ) } \arguments{ -\item{graph}{The input graph. It can also be \code{NULL} if \code{nodes} is given.} +\item{graph}{The input graph. It can also be \code{NULL} if \code{n} is given.} -\item{nodes}{The number of vertices. This is ignored if the graph is given.} +\item{n}{The number of vertices. This is ignored if the graph is given.} + +\item{...}{These dots are for future extensions and must be empty.} \item{mode}{This is the same as the \code{mode} argument of \code{degree()}. Ignored if \code{graph} is given and the graph is undirected.} \item{loops}{Logical, whether to consider loops edges when calculating the degree.} + +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} } \value{ Real scalar, the theoretical maximum (unnormalized) graph degree diff --git a/man/centr_eigen_tmax.Rd b/man/centr_eigen_tmax.Rd index 86ce59f90d..c68f1151f1 100644 --- a/man/centr_eigen_tmax.Rd +++ b/man/centr_eigen_tmax.Rd @@ -6,23 +6,29 @@ \usage{ centr_eigen_tmax( graph = NULL, - nodes = 0, + n = 0, + ..., directed = FALSE, - scale = deprecated() + scale = deprecated(), + nodes = deprecated() ) } \arguments{ \item{graph}{The input graph. It can also be \code{NULL}, if -\code{nodes} is given.} +\code{n} is given.} -\item{nodes}{The number of vertices. This is ignored if the graph is +\item{n}{The number of vertices. This is ignored if the graph is given.} +\item{...}{These dots are for future extensions and must be empty.} + \item{directed}{Logical, whether to consider edge directions during the calculation. Ignored in undirected graphs.} \item{scale}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Ignored. Computing eigenvector centralization requires normalized eigenvector centrality scores.} + +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} } \value{ Real scalar, the theoretical maximum (unnormalized) graph diff --git a/man/centralization.betweenness.tmax.Rd b/man/centralization.betweenness.tmax.Rd index fb9bbfd586..dcd8de0d6a 100644 --- a/man/centralization.betweenness.tmax.Rd +++ b/man/centralization.betweenness.tmax.Rd @@ -8,10 +8,9 @@ centralization.betweenness.tmax(graph = NULL, nodes = 0, directed = TRUE) } \arguments{ \item{graph}{The input graph. It can also be \code{NULL} if -\code{nodes} and \code{directed} are both given.} +\code{n} and \code{directed} are both given.} -\item{nodes}{The number of vertices. This is ignored if the graph is -given.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{directed}{Logical, whether to use directed shortest paths for calculating betweenness. Ignored if an undirected graph was diff --git a/man/centralization.closeness.tmax.Rd b/man/centralization.closeness.tmax.Rd index e1560171fc..7263c0ab32 100644 --- a/man/centralization.closeness.tmax.Rd +++ b/man/centralization.closeness.tmax.Rd @@ -12,10 +12,9 @@ centralization.closeness.tmax( } \arguments{ \item{graph}{The input graph. It can also be \code{NULL} if -\code{nodes} is given.} +\code{n} is given.} -\item{nodes}{The number of vertices. This is ignored if the graph is -given.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{mode}{This is the same as the \code{mode} argument of \code{closeness()}. Ignored if an undirected graph is given.} diff --git a/man/centralization.degree.tmax.Rd b/man/centralization.degree.tmax.Rd index 29d7b242e7..1809563818 100644 --- a/man/centralization.degree.tmax.Rd +++ b/man/centralization.degree.tmax.Rd @@ -12,9 +12,9 @@ centralization.degree.tmax( ) } \arguments{ -\item{graph}{The input graph. It can also be \code{NULL} if \code{nodes} is given.} +\item{graph}{The input graph. It can also be \code{NULL} if \code{n} is given.} -\item{nodes}{The number of vertices. This is ignored if the graph is given.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{mode}{This is the same as the \code{mode} argument of \code{degree()}. Ignored if \code{graph} is given and the graph is undirected.} diff --git a/man/centralization.evcent.tmax.Rd b/man/centralization.evcent.tmax.Rd index 7800a83252..f03685e797 100644 --- a/man/centralization.evcent.tmax.Rd +++ b/man/centralization.evcent.tmax.Rd @@ -13,10 +13,9 @@ centralization.evcent.tmax( } \arguments{ \item{graph}{The input graph. It can also be \code{NULL}, if -\code{nodes} is given.} +\code{n} is given.} -\item{nodes}{The number of vertices. This is ignored if the graph is -given.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{directed}{Logical, whether to consider edge directions during the calculation. Ignored in undirected graphs.} diff --git a/man/establishment.game.Rd b/man/establishment.game.Rd index c27ce60c40..aad71dc1ea 100644 --- a/man/establishment.game.Rd +++ b/man/establishment.game.Rd @@ -14,7 +14,7 @@ establishment.game( ) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{types}{The number of different vertex types.} diff --git a/man/forest.fire.game.Rd b/man/forest.fire.game.Rd index 28aa158ba6..6acc3c63bf 100644 --- a/man/forest.fire.game.Rd +++ b/man/forest.fire.game.Rd @@ -7,7 +7,7 @@ forest.fire.game(nodes, fw.prob, bw.factor = 1, ambs = 1, directed = TRUE) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{fw.prob}{The forward burning probability, see details below.} diff --git a/man/graph.graphdb.Rd b/man/graph.graphdb.Rd index bc45919b8a..309ad93fe8 100644 --- a/man/graph.graphdb.Rd +++ b/man/graph.graphdb.Rd @@ -30,7 +30,8 @@ values: \code{r001}, \code{r005}, \code{r01}, \code{r02}, \code{m2D}, \code{m4Dr6}, \code{b03}, \code{b03m}, \code{b06}, \code{b06m}, \code{b09}, \code{b09m}.} -\item{nodes}{The number of vertices in the graph.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} in +\code{\link[=graph_from_graphdb]{graph_from_graphdb()}} instead.} \item{pair}{Specifies which graph of the pair to read. Possible values: \code{A} and \code{B}.} diff --git a/man/graph_from_graphdb.Rd b/man/graph_from_graphdb.Rd index 3b87c241a5..b6218cef77 100644 --- a/man/graph_from_graphdb.Rd +++ b/man/graph_from_graphdb.Rd @@ -9,7 +9,7 @@ graph_from_graphdb( ..., prefix = "iso", type = "r001", - nodes = NULL, + n = NULL, pair = "A", which = 0, base = "https://github.com/igraph/graphsdb/raw/refs/heads/main", @@ -33,7 +33,7 @@ values: \code{r001}, \code{r005}, \code{r01}, \code{r02}, \code{m2D}, \code{m4Dr6}, \code{b03}, \code{b03m}, \code{b06}, \code{b06m}, \code{b09}, \code{b09m}.} -\item{nodes}{The number of vertices in the graph.} +\item{n}{The number of vertices in the graph.} \item{pair}{Specifies which graph of the pair to read. Possible values: \code{A} and \code{B}.} @@ -66,7 +66,7 @@ a local or remote graph database file. In this case we simply call \code{\link[=read_graph]{read_graph()}} with the proper arguments to read the file. If \code{url} is \code{NULL}, and this is the default, then the filename is -assembled from the \code{base}, \code{prefix}, \code{type}, \code{nodes}, +assembled from the \code{base}, \code{prefix}, \code{type}, \code{n}, \code{pair} and \code{which} arguments. Unfortunately the original graph database homepage is now defunct, but see diff --git a/man/grg.game.Rd b/man/grg.game.Rd index 22343e3048..f87b55774c 100644 --- a/man/grg.game.Rd +++ b/man/grg.game.Rd @@ -7,7 +7,7 @@ grg.game(nodes, radius, torus = FALSE, coords = FALSE) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{radius}{The radius within which the vertices will be connected by an edge.} diff --git a/man/preference.game.Rd b/man/preference.game.Rd index d55dea8377..4f269e429e 100644 --- a/man/preference.game.Rd +++ b/man/preference.game.Rd @@ -15,7 +15,7 @@ preference.game( ) } \arguments{ -\item{nodes}{The number of vertices in the graphs.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{types}{The number of different vertex types.} diff --git a/man/sample_forestfire.Rd b/man/sample_forestfire.Rd index aeff07ef5f..c15e7baebe 100644 --- a/man/sample_forestfire.Rd +++ b/man/sample_forestfire.Rd @@ -5,16 +5,17 @@ \title{Forest Fire Network Model} \usage{ sample_forestfire( - nodes, + n, fw.prob, ..., bw.factor = 1, ambs = 1, - directed = TRUE + directed = TRUE, + nodes = deprecated() ) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{n}{The number of vertices in the graph.} \item{fw.prob}{The forward burning probability, see details below.} @@ -26,6 +27,8 @@ probability is calculated as \code{bw.factor*fw.prob}.} \item{ambs}{The number of ambassador vertices.} \item{directed}{Logical, whether to create a directed graph.} + +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} } \value{ A simple graph, possibly directed if the \code{directed} argument is diff --git a/man/sample_grg.Rd b/man/sample_grg.Rd index 8b83e6b140..72bf143bb0 100644 --- a/man/sample_grg.Rd +++ b/man/sample_grg.Rd @@ -5,12 +5,12 @@ \alias{grg} \title{Geometric random graphs} \usage{ -sample_grg(nodes, radius, ..., torus = FALSE, coords = FALSE) +sample_grg(n, radius, ..., torus = FALSE, coords = FALSE, nodes = deprecated()) -grg(nodes, radius, ..., torus = FALSE, coords = FALSE) +grg(n, radius, ..., torus = FALSE, coords = FALSE, nodes = deprecated()) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{n}{The number of vertices in the graph.} \item{radius}{The radius within which the vertices will be connected by an edge.} @@ -21,6 +21,8 @@ edge.} \item{coords}{Logical, whether to add the positions of the vertices as vertex attributes called \sQuote{\code{x}} and \sQuote{\code{y}}.} + +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} } \value{ A graph object. If \code{coords} is \code{TRUE} then with vertex diff --git a/man/sample_pref.Rd b/man/sample_pref.Rd index 35b69cbd0d..a26ffb9eb7 100644 --- a/man/sample_pref.Rd +++ b/man/sample_pref.Rd @@ -8,47 +8,51 @@ \title{Trait-based random generation} \usage{ sample_pref( - nodes, + n, types, ..., type.dist = NULL, fixed.sizes = FALSE, pref.matrix = NULL, directed = FALSE, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) pref( - nodes, + n, types, ..., type.dist = NULL, fixed.sizes = FALSE, pref.matrix = NULL, directed = FALSE, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) sample_asym_pref( - nodes, + n, types, ..., type.dist.matrix = NULL, pref.matrix = NULL, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) asym_pref( - nodes, + n, types, ..., type.dist.matrix = NULL, pref.matrix = NULL, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) } \arguments{ -\item{nodes}{The number of vertices in the graphs.} +\item{n}{The number of vertices in the graphs.} \item{types}{The number of different vertex types.} @@ -72,6 +76,8 @@ preferences to one.} \item{loops}{Logical, whether self-loops are allowed in the graph.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} + \item{type.dist.matrix}{The joint distribution of the in- and out-vertex types. The default \code{NULL} gives a uniform distribution.} } diff --git a/man/sample_traits_callaway.Rd b/man/sample_traits_callaway.Rd index 29f831bc9b..a86d5de32d 100644 --- a/man/sample_traits_callaway.Rd +++ b/man/sample_traits_callaway.Rd @@ -8,47 +8,51 @@ \title{Graph generation based on different vertex types} \usage{ sample_traits_callaway( - nodes, + n, types, ..., edge.per.step = 1, type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) traits_callaway( - nodes, + n, types, ..., edge.per.step = 1, type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) sample_traits( - nodes, + n, types, k = 1, ..., type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) traits( - nodes, + n, types, k = 1, ..., type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{n}{The number of vertices in the graph.} \item{types}{The number of different vertex types.} @@ -65,6 +69,8 @@ The default \code{NULL} sets all preferences to one.} \item{directed}{Logical, whether to generate directed graphs.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} + \item{k}{The number of trials per time step, see details below.} } \value{ diff --git a/tests/testthat/_snaps/foreign.md b/tests/testthat/_snaps/foreign.md index 412dbd28ff..efa04eaf47 100644 --- a/tests/testthat/_snaps/foreign.md +++ b/tests/testthat/_snaps/foreign.md @@ -48,12 +48,12 @@ graph_from_graphdb() Condition Error in `graph_from_graphdb()`: - ! Either `nodes`' or ``url`' must be non-null. + ! Either `n`' or ``url`' must be non-null. --- Code - graph_from_graphdb(nodes = 10, prefix = "not_existing") + graph_from_graphdb(n = 10, prefix = "not_existing") Condition Error in `graph_from_graphdb()`: ! not_existing is not a valid prefix. @@ -62,7 +62,7 @@ --- Code - graph_from_graphdb(nodes = 10, type = "not_existing") + graph_from_graphdb(n = 10, type = "not_existing") Condition Error in `graph_from_graphdb()`: ! not_existing is not a valid graph type. diff --git a/tests/testthat/_snaps/games.md b/tests/testthat/_snaps/games.md index 56ba3f0533..77558b79c6 100644 --- a/tests/testthat/_snaps/games.md +++ b/tests/testthat/_snaps/games.md @@ -16,3 +16,21 @@ ! Cannot realize the given degree sequence as an undirected, simple graph. Invalid value Source: : +# sample_grg(nodes = ) is deprecated but still works + + Code + g <- sample_grg(nodes = 10, radius = 1) + Condition + Warning: + The `nodes` argument of `sample_grg()` is deprecated as of igraph 3.0.0. + i Please use the `n` argument instead. + +# sample_grg() rejects `n` supplied both directly and as `nodes` + + Code + sample_grg(10, radius = 1, nodes = 10) + Condition + Error in `sample_grg()`: + ! Argument `n` of `sample_grg()` was supplied more than once. + i It was also supplied via its legacy name `nodes`. + diff --git a/tests/testthat/test-centralization.R b/tests/testthat/test-centralization.R index 9161e1262e..7fb01e91c6 100644 --- a/tests/testthat/test-centralization.R +++ b/tests/testthat/test-centralization.R @@ -70,7 +70,7 @@ test_that("centr_betw_tmax() covers migrated tail args and positional recovery", # The graph form and the vertex-count form must agree. expect_equal(centr_betw_tmax(g, directed = FALSE), 24) - expect_equal(centr_betw_tmax(nodes = 5, directed = FALSE), 24) + expect_equal(centr_betw_tmax(n = 5, directed = FALSE), 24) # And they match what centr_betw() reports. expect_equal( centr_betw(g, directed = FALSE, normalized = FALSE)$theoretical_max, @@ -110,7 +110,7 @@ test_that("centr_clo_tmax() covers migrated tail args and positional recovery", # The graph form and the vertex-count form must agree. expect_equal(centr_clo_tmax(g, mode = "in"), 3.2) - expect_equal(centr_clo_tmax(nodes = 5, mode = "in"), 3.2) + expect_equal(centr_clo_tmax(n = 5, mode = "in"), 3.2) # And they match what centr_clo() reports. expect_equal( centr_clo(g, mode = "in", normalized = FALSE)$theoretical_max, @@ -136,3 +136,20 @@ test_that("centralize() covers migrated tail args and positional recovery", { ) expect_identical(res_legacy, centralize(scores, theoretical.max = 12)) }) + +# ---- nodes -> n rename ------------------------------------------------ + +test_that("centr_*_tmax(nodes = ) is deprecated but still works", { + lifecycle::expect_deprecated( + res_betw <- centr_betw_tmax(nodes = 5, directed = FALSE) + ) + expect_identical(res_betw, centr_betw_tmax(n = 5, directed = FALSE)) + + lifecycle::expect_deprecated( + res_degree <- centr_degree_tmax(nodes = 5, mode = "all", loops = TRUE) + ) + expect_identical( + res_degree, + centr_degree_tmax(n = 5, mode = "all", loops = TRUE) + ) +}) diff --git a/tests/testthat/test-foreign.R b/tests/testthat/test-foreign.R index 0332707c7e..29e59cc6d5 100644 --- a/tests/testthat/test-foreign.R +++ b/tests/testthat/test-foreign.R @@ -66,13 +66,13 @@ test_that("graph_from_graphdb works", { # docker run --rm -ti -v $PWD:/rigraph -e MAKEFLAGS=-j4 ghcr.io/cynkra/r-debug/r-debug-csan-igraph:latest RDcsan -q -e 'filename <- "/rigraph/DESCRIPTION"; gz_file_con <- file(filename, open = "rb"); file_con <- gzcon(gz_file_con); close(file_con); gc()' skip_if(Sys.getenv("R_SANITIZER") == "true") - expect_silent(graph_from_graphdb(nodes = 1000)) + expect_silent(graph_from_graphdb(n = 1000)) expect_snapshot_igraph_error(graph_from_graphdb()) expect_snapshot_igraph_error( - graph_from_graphdb(nodes = 10, prefix = "not_existing") + graph_from_graphdb(n = 10, prefix = "not_existing") ) expect_snapshot_igraph_error( - graph_from_graphdb(nodes = 10, type = "not_existing") + graph_from_graphdb(n = 10, type = "not_existing") ) }) @@ -95,7 +95,7 @@ test_that("graph_from_graphdb() accepts every tail argument by name", { url = NULL, prefix = "iso", type = "r001", - nodes = 1000, + n = 1000, pair = "A", which = 0, base = "https://github.com/igraph/graphsdb/raw/refs/heads/main", @@ -120,7 +120,7 @@ test_that("graph_from_graphdb() wires up legacy positional recovery", { # a download. lifecycle::expect_deprecated( expect_error( - graph_from_graphdb(NULL, "not_existing", nodes = 10), + graph_from_graphdb(NULL, "not_existing", n = 10), regexp = "not a valid prefix" ) ) diff --git a/tests/testthat/test-games.R b/tests/testthat/test-games.R index f2034ffd21..fdbb330e22 100644 --- a/tests/testthat/test-games.R +++ b/tests/testthat/test-games.R @@ -1702,3 +1702,43 @@ test_that("sample_correlated_gnp() recovers positional p", { sample_correlated_gnp(base_graph, 0.8, p = 0.3) ) }) + +# ---- nodes -> n rename ------------------------------------------------ + +test_that("sample_grg(nodes = ) is deprecated but still works", { + rlang::local_options(lifecycle_verbosity = "warning") + igraph_local_seed(42) + expected <- sample_grg(n = 10, radius = 1) + igraph_local_seed(42) + expect_snapshot( + g <- sample_grg(nodes = 10, radius = 1) + ) + expect_identical_graphs(g, expected) +}) + +test_that("sample_grg() rejects `n` supplied both directly and as `nodes`", { + rlang::local_options(lifecycle_verbosity = "warning") + expect_snapshot( + sample_grg(10, radius = 1, nodes = 10), + error = TRUE + ) +}) + +test_that("sample_pref(nodes = ) and sample_forestfire(nodes = ) are deprecated but still work", { + igraph_local_seed(1) + lifecycle::expect_deprecated( + g_pref_legacy <- sample_pref(nodes = 20, types = 2) + ) + igraph_local_seed(1) + expect_identical_graphs(g_pref_legacy, sample_pref(n = 20, types = 2)) + + igraph_local_seed(1) + lifecycle::expect_deprecated( + g_fire_legacy <- sample_forestfire(nodes = 30, fw.prob = 0.2) + ) + igraph_local_seed(1) + expect_identical_graphs( + g_fire_legacy, + sample_forestfire(n = 30, fw.prob = 0.2) + ) +}) diff --git a/tools/migrations/centralization.R b/tools/migrations/centralization.R index 0844a295b1..019e811c21 100644 --- a/tools/migrations/centralization.R +++ b/tools/migrations/centralization.R @@ -18,9 +18,10 @@ migrations <- list( old = function(graph, nodes, directed) {}, new = function( graph = NULL, - nodes = 0, + n = 0, ..., - directed = TRUE + directed = TRUE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -40,9 +41,10 @@ migrations <- list( old = function(graph, nodes, mode) {}, new = function( graph = NULL, - nodes = 0, + n = 0, ..., - mode = c("out", "in", "all", "total") + mode = c("out", "in", "all", "total"), + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -59,6 +61,32 @@ migrations <- list( when = "3.0.0" ), + centr_degree_tmax = list( + old = function(graph, nodes, mode, loops) {}, + new = function( + graph = NULL, + n = 0, + ..., + mode = c("all", "out", "in", "total"), + loops, + nodes = deprecated() + ) {}, + when = "3.0.0" + ), + + centr_eigen_tmax = list( + old = function(graph, nodes, directed, scale) {}, + new = function( + graph = NULL, + n = 0, + ..., + directed = FALSE, + scale = deprecated(), + nodes = deprecated() + ) {}, + when = "3.0.0" + ), + centralize = list( old = function(scores, theoretical.max, normalized) {}, new = function( diff --git a/tools/migrations/games.R b/tools/migrations/games.R index 89d95e6fc1..d2e54ddbee 100644 --- a/tools/migrations/games.R +++ b/tools/migrations/games.R @@ -6,12 +6,13 @@ migrations <- list( asym_pref = list( old = function(nodes, types, type.dist.matrix, pref.matrix, loops) {}, new = function( - nodes, + n, types, ..., type.dist.matrix = NULL, pref.matrix = NULL, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -81,11 +82,12 @@ migrations <- list( grg = list( old = function(nodes, radius, torus, coords) {}, new = function( - nodes, + n, radius, ..., torus = FALSE, - coords = FALSE + coords = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -180,14 +182,15 @@ migrations <- list( loops ) {}, new = function( - nodes, + n, types, ..., type.dist = NULL, fixed.sizes = FALSE, pref.matrix = NULL, directed = FALSE, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -195,12 +198,13 @@ migrations <- list( sample_asym_pref = list( old = function(nodes, types, type.dist.matrix, pref.matrix, loops) {}, new = function( - nodes, + n, types, ..., type.dist.matrix = NULL, pref.matrix = NULL, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -311,12 +315,13 @@ migrations <- list( sample_forestfire = list( old = function(nodes, fw.prob, bw.factor, ambs, directed) {}, new = function( - nodes, + n, fw.prob, ..., bw.factor = 1, ambs = 1, - directed = TRUE + directed = TRUE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -348,11 +353,12 @@ migrations <- list( sample_grg = list( old = function(nodes, radius, torus, coords) {}, new = function( - nodes, + n, radius, ..., torus = FALSE, - coords = FALSE + coords = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -463,14 +469,15 @@ migrations <- list( loops ) {}, new = function( - nodes, + n, types, ..., type.dist = NULL, fixed.sizes = FALSE, pref.matrix = NULL, directed = FALSE, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -505,13 +512,14 @@ migrations <- list( sample_traits = list( old = function(nodes, types, k, type.dist, pref.matrix, directed) {}, new = function( - nodes, + n, types, k = 1, ..., type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -526,13 +534,14 @@ migrations <- list( directed ) {}, new = function( - nodes, + n, types, ..., edge.per.step = 1, type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -567,13 +576,14 @@ migrations <- list( traits = list( old = function(nodes, types, k, type.dist, pref.matrix, directed) {}, new = function( - nodes, + n, types, k = 1, ..., type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -588,13 +598,14 @@ migrations <- list( directed ) {}, new = function( - nodes, + n, types, ..., edge.per.step = 1, type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ) diff --git a/tools/migrations/misc.R b/tools/migrations/misc.R index 471d08a71a..dfb74867dd 100644 --- a/tools/migrations/misc.R +++ b/tools/migrations/misc.R @@ -28,7 +28,7 @@ migrations <- list( url, prefix, type, - nodes, + nodes = n, pair, which, base, @@ -40,7 +40,7 @@ migrations <- list( ..., prefix = "iso", type = "r001", - nodes = NULL, + n = NULL, pair = "A", which = 0, base = "https://github.com/igraph/graphsdb/raw/refs/heads/main", From 0cde4bd73f04ae97573b0345c4f9a77bbfdf27e5 Mon Sep 17 00:00:00 2001 From: David Schoch Date: Wed, 2 Dec 2026 21:05:58 +0100 Subject: [PATCH 2/5] test: Cover the remaining `nodes = ` renames centr_clo_tmax(), centr_eigen_tmax(), graph_from_graphdb(), sample_asym_pref(), sample_traits(), sample_traits_callaway() and the grg(), pref(), asym_pref(), traits() and traits_callaway() specs were renamed without a test that the legacy name still works. Co-Authored-By: Claude Opus 5.5 --- tests/testthat/test-centralization.R | 10 +++++ tests/testthat/test-foreign.R | 16 ++++++++ tests/testthat/test-games.R | 57 ++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/tests/testthat/test-centralization.R b/tests/testthat/test-centralization.R index 7fb01e91c6..57015d2ced 100644 --- a/tests/testthat/test-centralization.R +++ b/tests/testthat/test-centralization.R @@ -152,4 +152,14 @@ test_that("centr_*_tmax(nodes = ) is deprecated but still works", { res_degree, centr_degree_tmax(n = 5, mode = "all", loops = TRUE) ) + + lifecycle::expect_deprecated( + res_clo <- centr_clo_tmax(nodes = 5, mode = "all") + ) + expect_identical(res_clo, centr_clo_tmax(n = 5, mode = "all")) + + lifecycle::expect_deprecated( + res_eigen <- centr_eigen_tmax(nodes = 5, directed = FALSE) + ) + expect_identical(res_eigen, centr_eigen_tmax(n = 5, directed = FALSE)) }) diff --git a/tests/testthat/test-foreign.R b/tests/testthat/test-foreign.R index 57b645dd5f..0da2be7cfe 100644 --- a/tests/testthat/test-foreign.R +++ b/tests/testthat/test-foreign.R @@ -79,6 +79,22 @@ test_that("graph_from_graphdb works", { expect_vcount(g, 1000) }) +test_that("graph_from_graphdb(nodes = ) is deprecated but still works", { + # An unknown prefix fails before any download, so no network is needed. + rlang::local_options(lifecycle_verbosity = "warning") + lifecycle::expect_deprecated( + err_legacy <- tryCatch( + graph_from_graphdb(nodes = 10, prefix = "not_existing"), + error = identity + ) + ) + err <- tryCatch( + graph_from_graphdb(n = 10, prefix = "not_existing"), + error = identity + ) + expect_identical(conditionMessage(err_legacy), conditionMessage(err)) +}) + # ---- ellipsis migration: argument coverage ---------------------------------- test_that("graph_from_graphdb() accepts every tail argument by name", { diff --git a/tests/testthat/test-games.R b/tests/testthat/test-games.R index 9097548cc2..d7344f8442 100644 --- a/tests/testthat/test-games.R +++ b/tests/testthat/test-games.R @@ -1811,6 +1811,63 @@ test_that("sample_pref(nodes = ) and sample_forestfire(nodes = ) are deprecated ) }) +test_that("the remaining generators and spec twins accept `nodes = ` with a deprecation", { + rlang::local_options(lifecycle_verbosity = "warning") + + graph_cases <- list( + list( + quote(sample_asym_pref(nodes = 20, types = 2)), + quote(sample_asym_pref(n = 20, types = 2)) + ), + list( + quote(sample_(grg(nodes = 20, radius = 0.3))), + quote(sample_(grg(n = 20, radius = 0.3))) + ), + list( + quote(sample_(pref(nodes = 20, types = 2))), + quote(sample_(pref(n = 20, types = 2))) + ), + list( + quote(sample_(asym_pref(nodes = 20, types = 2))), + quote(sample_(asym_pref(n = 20, types = 2))) + ) + ) + for (case in graph_cases) { + lifecycle::expect_deprecated( + g_legacy <- igraph_with_seed(1, eval(case[[1]])) + ) + expect_identical_graphs(g_legacy, igraph_with_seed(1, eval(case[[2]]))) + } + + # The traits generators return a list holding the graph. + list_cases <- list( + list( + quote(sample_traits(nodes = 20, types = 2, k = 2)), + quote(sample_traits(n = 20, types = 2, k = 2)) + ), + list( + quote(sample_(traits(nodes = 20, types = 2, k = 2))), + quote(sample_(traits(n = 20, types = 2, k = 2))) + ), + list( + quote(sample_traits_callaway(nodes = 20, types = 2)), + quote(sample_traits_callaway(n = 20, types = 2)) + ), + list( + quote(sample_(traits_callaway(nodes = 20, types = 2))), + quote(sample_(traits_callaway(n = 20, types = 2))) + ) + ) + for (case in list_cases) { + lifecycle::expect_deprecated( + res_legacy <- igraph_with_seed(1, eval(case[[1]])) + ) + res <- igraph_with_seed(1, eval(case[[2]])) + expect_identical_graphs(res_legacy$graph, res$graph) + expect_identical(res_legacy[-1], res[-1]) + } +}) + test_that("sample_islands() random stream for a fixed seed", { # Pins the random numbers the C core draws for this generator. igraph_local_seed(42) From 9f674155039ed2f037c860543ce2b2bc07ff3ad9 Mon Sep 17 00:00:00 2001 From: David Schoch Date: Thu, 3 Dec 2026 09:55:51 +0100 Subject: [PATCH 3/5] test: Compare the traits generators by graph now that they return one Co-Authored-By: Claude Opus 5.5 --- tests/testthat/test-games.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-games.R b/tests/testthat/test-games.R index ecf161a980..a614f2a5d7 100644 --- a/tests/testthat/test-games.R +++ b/tests/testthat/test-games.R @@ -1835,7 +1835,7 @@ test_that("the remaining generators and spec twins accept `nodes = ` with a depr expect_identical_graphs(g_legacy, igraph_with_seed(1, eval(case[[2]]))) } - # The traits generators return a list holding the graph. + # The traits generators store the vertex types as a vertex attribute. list_cases <- list( list( quote(sample_traits(nodes = 20, types = 2, k = 2)), @@ -1859,8 +1859,8 @@ test_that("the remaining generators and spec twins accept `nodes = ` with a depr res_legacy <- igraph_with_seed(1, eval(case[[1]])) ) res <- igraph_with_seed(1, eval(case[[2]])) - expect_identical_graphs(res_legacy$graph, res$graph) - expect_identical(res_legacy[-1], res[-1]) + expect_identical_graphs(res_legacy, res) + expect_identical(V(res_legacy)$type, V(res)$type) } }) From c38879135668c2e0e074b22c108f51500be7cb52 Mon Sep 17 00:00:00 2001 From: David Schoch Date: Thu, 3 Dec 2026 15:15:48 +0100 Subject: [PATCH 4/5] refactor: Let the generator own the `nodes` renames The generator now re-matches a call that uses an old head name against the old signature, so the hand-written `nodes` -> `n` bridges are gone. A call like `sample_grg(nodes = 10, 0.5, TRUE)` keeps its old meaning (`torus = TRUE`) instead of failing with "`n` supplied more than once". Co-Authored-By: Claude Opus 5.5 --- R/centralization.R | 210 ++++++++---- R/games.R | 600 +++++++++++++++++++++++---------- tests/testthat/_snaps/games.md | 2 +- tests/testthat/test-games.R | 13 +- 4 files changed, 583 insertions(+), 242 deletions(-) diff --git a/R/centralization.R b/R/centralization.R index 7dde5402eb..317cbb4c8c 100644 --- a/R/centralization.R +++ b/R/centralization.R @@ -503,7 +503,43 @@ centr_degree_tmax <- function( ) { # BEGIN GENERATED ARG_HANDLE: centr_degree_tmax, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: centr_degree_tmax(graph, nodes, mode, loops) + .old_signature <- function(graph, nodes, mode, loops, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(graph)) base::c(graph = "graph"), + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(mode)) base::c(mode = "mode"), + if (!base::missing(loops)) base::c(loops = "loops") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn centr_degree_tmax}.") + .arg_explicit <- base::c("graph", "n", "mode", "loops", "nodes")[base::pmatch(.arg_extra, base::c("graph", "n", "mode", "loops", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn centr_degree_tmax}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn centr_degree_tmax} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "centr_degree_tmax(nodes = )", "centr_degree_tmax(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("mode", "loops"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `centr_degree_tmax()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: centr_degree_tmax(", base::paste(base::c("graph", "n", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { # Pre-3.0.0 signature: centr_degree_tmax(graph, nodes, mode, loops) .old_signature <- function(mode, loops, ...) { if (...length() > 0L) { @@ -543,21 +579,6 @@ centr_degree_tmax <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn centr_degree_tmax} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "centr_degree_tmax(nodes = )", - "centr_degree_tmax(n = )" - ) - n <- nodes - } - if (!lifecycle::is_present(loops)) { lifecycle::deprecate_stop( when = "2.0.0", @@ -722,7 +743,42 @@ centr_betw_tmax <- function( ) { # BEGIN GENERATED ARG_HANDLE: centr_betw_tmax, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: centr_betw_tmax(graph, nodes, directed) + .old_signature <- function(graph, nodes, directed, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(graph)) base::c(graph = "graph"), + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(directed)) base::c(directed = "directed") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn centr_betw_tmax}.") + .arg_explicit <- base::c("graph", "n", "directed", "nodes")[base::pmatch(.arg_extra, base::c("graph", "n", "directed", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn centr_betw_tmax}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn centr_betw_tmax} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "centr_betw_tmax(nodes = )", "centr_betw_tmax(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("directed"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `centr_betw_tmax()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: centr_betw_tmax(", base::paste(base::c("graph", "n", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { # Pre-3.0.0 signature: centr_betw_tmax(graph, nodes, directed) .old_signature <- function(directed, ...) { if (...length() > 0L) { @@ -760,21 +816,6 @@ centr_betw_tmax <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn centr_betw_tmax} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "centr_betw_tmax(nodes = )", - "centr_betw_tmax(n = )" - ) - n <- nodes - } - centralization_betweenness_tmax_impl( graph = graph, nodes = n, @@ -909,7 +950,42 @@ centr_clo_tmax <- function( ) { # BEGIN GENERATED ARG_HANDLE: centr_clo_tmax, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: centr_clo_tmax(graph, nodes, mode) + .old_signature <- function(graph, nodes, mode, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(graph)) base::c(graph = "graph"), + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(mode)) base::c(mode = "mode") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn centr_clo_tmax}.") + .arg_explicit <- base::c("graph", "n", "mode", "nodes")[base::pmatch(.arg_extra, base::c("graph", "n", "mode", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn centr_clo_tmax}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn centr_clo_tmax} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "centr_clo_tmax(nodes = )", "centr_clo_tmax(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("mode"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `centr_clo_tmax()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: centr_clo_tmax(", base::paste(base::c("graph", "n", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { # Pre-3.0.0 signature: centr_clo_tmax(graph, nodes, mode) .old_signature <- function(mode, ...) { if (...length() > 0L) { @@ -947,21 +1023,6 @@ centr_clo_tmax <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn centr_clo_tmax} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "centr_clo_tmax(nodes = )", - "centr_clo_tmax(n = )" - ) - n <- nodes - } - centralization_closeness_tmax_impl( graph = graph, nodes = n, @@ -1081,7 +1142,43 @@ centr_eigen_tmax <- function( ) { # BEGIN GENERATED ARG_HANDLE: centr_eigen_tmax, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: centr_eigen_tmax(graph, nodes, directed, scale) + .old_signature <- function(graph, nodes, directed, scale, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(graph)) base::c(graph = "graph"), + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(directed)) base::c(directed = "directed"), + if (!base::missing(scale)) base::c(scale = "scale") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn centr_eigen_tmax}.") + .arg_explicit <- base::c("graph", "n", "directed", "scale", "nodes")[base::pmatch(.arg_extra, base::c("graph", "n", "directed", "scale", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn centr_eigen_tmax}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn centr_eigen_tmax} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "centr_eigen_tmax(nodes = )", "centr_eigen_tmax(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("directed", "scale"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `centr_eigen_tmax()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: centr_eigen_tmax(", base::paste(base::c("graph", "n", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { # Pre-3.0.0 signature: centr_eigen_tmax(graph, nodes, directed, scale) .old_signature <- function(directed, scale, ...) { if (...length() > 0L) { @@ -1121,21 +1218,6 @@ centr_eigen_tmax <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn centr_eigen_tmax} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "centr_eigen_tmax(nodes = )", - "centr_eigen_tmax(n = )" - ) - n <- nodes - } - if (lifecycle::is_present(scale)) { lifecycle::deprecate_warn( "2.2.0", diff --git a/R/games.R b/R/games.R index 5721bb5945..e96517f1b0 100644 --- a/R/games.R +++ b/R/games.R @@ -2280,7 +2280,45 @@ sample_traits_callaway <- function( ) { # BEGIN GENERATED ARG_HANDLE: sample_traits_callaway, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: sample_traits_callaway(nodes, types, edge.per.step, type.dist, pref.matrix, directed) + .old_signature <- function(nodes, types, edge.per.step, type.dist, pref.matrix, directed, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(types)) base::c(types = "types"), + if (!base::missing(edge.per.step)) base::c(edge.per.step = "edge.per.step"), + if (!base::missing(type.dist)) base::c(type.dist = "type.dist"), + if (!base::missing(pref.matrix)) base::c(pref.matrix = "pref.matrix"), + if (!base::missing(directed)) base::c(directed = "directed") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn sample_traits_callaway}.") + .arg_explicit <- base::c("n", "types", "edge.per.step", "type.dist", "pref.matrix", "directed", "nodes")[base::pmatch(.arg_extra, base::c("n", "types", "edge.per.step", "type.dist", "pref.matrix", "directed", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn sample_traits_callaway}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn sample_traits_callaway} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "sample_traits_callaway(nodes = )", "sample_traits_callaway(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("edge.per.step", "type.dist", "pref.matrix", "directed"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `sample_traits_callaway()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: sample_traits_callaway(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("t", "ty", "typ", "type")) if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn sample_traits_callaway}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: sample_traits_callaway(nodes, types, edge.per.step, type.dist, pref.matrix, directed) @@ -2326,21 +2364,6 @@ sample_traits_callaway <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn sample_traits_callaway} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "sample_traits_callaway(nodes = )", - "sample_traits_callaway(n = )" - ) - n <- nodes - } - if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2386,7 +2409,45 @@ traits_callaway <- function( ) { # BEGIN GENERATED ARG_HANDLE: traits_callaway, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: traits_callaway(nodes, types, edge.per.step, type.dist, pref.matrix, directed) + .old_signature <- function(nodes, types, edge.per.step, type.dist, pref.matrix, directed, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(types)) base::c(types = "types"), + if (!base::missing(edge.per.step)) base::c(edge.per.step = "edge.per.step"), + if (!base::missing(type.dist)) base::c(type.dist = "type.dist"), + if (!base::missing(pref.matrix)) base::c(pref.matrix = "pref.matrix"), + if (!base::missing(directed)) base::c(directed = "directed") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn traits_callaway}.") + .arg_explicit <- base::c("n", "types", "edge.per.step", "type.dist", "pref.matrix", "directed", "nodes")[base::pmatch(.arg_extra, base::c("n", "types", "edge.per.step", "type.dist", "pref.matrix", "directed", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn traits_callaway}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn traits_callaway} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "traits_callaway(nodes = )", "traits_callaway(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("edge.per.step", "type.dist", "pref.matrix", "directed"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `traits_callaway()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: traits_callaway(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("t", "ty", "typ", "type")) if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn traits_callaway}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: traits_callaway(nodes, types, edge.per.step, type.dist, pref.matrix, directed) @@ -2432,21 +2493,6 @@ traits_callaway <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn traits_callaway} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "traits_callaway(nodes = )", - "traits_callaway(n = )" - ) - n <- nodes - } - if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2480,7 +2526,45 @@ sample_traits <- function( ) { # BEGIN GENERATED ARG_HANDLE: sample_traits, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: sample_traits(nodes, types, k, type.dist, pref.matrix, directed) + .old_signature <- function(nodes, types, k, type.dist, pref.matrix, directed, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(types)) base::c(types = "types"), + if (!base::missing(k)) base::c(k = "k"), + if (!base::missing(type.dist)) base::c(type.dist = "type.dist"), + if (!base::missing(pref.matrix)) base::c(pref.matrix = "pref.matrix"), + if (!base::missing(directed)) base::c(directed = "directed") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn sample_traits}.") + .arg_explicit <- base::c("n", "types", "k", "type.dist", "pref.matrix", "directed", "nodes")[base::pmatch(.arg_extra, base::c("n", "types", "k", "type.dist", "pref.matrix", "directed", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn sample_traits}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn sample_traits} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "sample_traits(nodes = )", "sample_traits(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("type.dist", "pref.matrix", "directed"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `sample_traits()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: sample_traits(", base::paste(base::c("n", "types", "k", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("t", "ty", "typ", "type")) if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn sample_traits}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: sample_traits(nodes, types, k, type.dist, pref.matrix, directed) @@ -2524,21 +2608,6 @@ sample_traits <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn sample_traits} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "sample_traits(nodes = )", - "sample_traits(n = )" - ) - n <- nodes - } - if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2580,7 +2649,45 @@ traits <- function( ) { # BEGIN GENERATED ARG_HANDLE: traits, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: traits(nodes, types, k, type.dist, pref.matrix, directed) + .old_signature <- function(nodes, types, k, type.dist, pref.matrix, directed, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(types)) base::c(types = "types"), + if (!base::missing(k)) base::c(k = "k"), + if (!base::missing(type.dist)) base::c(type.dist = "type.dist"), + if (!base::missing(pref.matrix)) base::c(pref.matrix = "pref.matrix"), + if (!base::missing(directed)) base::c(directed = "directed") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn traits}.") + .arg_explicit <- base::c("n", "types", "k", "type.dist", "pref.matrix", "directed", "nodes")[base::pmatch(.arg_extra, base::c("n", "types", "k", "type.dist", "pref.matrix", "directed", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn traits}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn traits} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "traits(nodes = )", "traits(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("type.dist", "pref.matrix", "directed"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `traits()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: traits(", base::paste(base::c("n", "types", "k", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("t", "ty", "typ", "type")) if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn traits}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: traits(nodes, types, k, type.dist, pref.matrix, directed) @@ -2624,21 +2731,6 @@ traits <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn traits} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "traits(nodes = )", - "traits(n = )" - ) - n <- nodes - } - if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2700,7 +2792,43 @@ sample_grg <- function( ) { # BEGIN GENERATED ARG_HANDLE: sample_grg, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: sample_grg(nodes, radius, torus, coords) + .old_signature <- function(nodes, radius, torus, coords, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(radius)) base::c(radius = "radius"), + if (!base::missing(torus)) base::c(torus = "torus"), + if (!base::missing(coords)) base::c(coords = "coords") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn sample_grg}.") + .arg_explicit <- base::c("n", "radius", "torus", "coords", "nodes")[base::pmatch(.arg_extra, base::c("n", "radius", "torus", "coords", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn sample_grg}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn sample_grg} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "sample_grg(nodes = )", "sample_grg(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("torus", "coords"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `sample_grg()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: sample_grg(", base::paste(base::c("n", "radius", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { # Pre-3.0.0 signature: sample_grg(nodes, radius, torus, coords) .old_signature <- function(torus, coords, ...) { if (...length() > 0L) { @@ -2740,21 +2868,6 @@ sample_grg <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn sample_grg} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "sample_grg(nodes = )", - "sample_grg(n = )" - ) - n <- nodes - } - on.exit(.Call(Rx_igraph_finalizer)) res <- .Call( Rx_igraph_grg_game, @@ -2788,7 +2901,43 @@ grg <- function( ) { # BEGIN GENERATED ARG_HANDLE: grg, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: grg(nodes, radius, torus, coords) + .old_signature <- function(nodes, radius, torus, coords, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(radius)) base::c(radius = "radius"), + if (!base::missing(torus)) base::c(torus = "torus"), + if (!base::missing(coords)) base::c(coords = "coords") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn grg}.") + .arg_explicit <- base::c("n", "radius", "torus", "coords", "nodes")[base::pmatch(.arg_extra, base::c("n", "radius", "torus", "coords", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn grg}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn grg} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "grg(nodes = )", "grg(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("torus", "coords"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `grg()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: grg(", base::paste(base::c("n", "radius", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { # Pre-3.0.0 signature: grg(nodes, radius, torus, coords) .old_signature <- function(torus, coords, ...) { if (...length() > 0L) { @@ -2828,21 +2977,6 @@ grg <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn grg} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "grg(nodes = )", - "grg(n = )" - ) - n <- nodes - } - constructor_spec( sample_grg, n = n, @@ -2929,7 +3063,46 @@ sample_pref <- function( ) { # BEGIN GENERATED ARG_HANDLE: sample_pref, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: sample_pref(nodes, types, type.dist, fixed.sizes, pref.matrix, directed, loops) + .old_signature <- function(nodes, types, type.dist, fixed.sizes, pref.matrix, directed, loops, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(types)) base::c(types = "types"), + if (!base::missing(type.dist)) base::c(type.dist = "type.dist"), + if (!base::missing(fixed.sizes)) base::c(fixed.sizes = "fixed.sizes"), + if (!base::missing(pref.matrix)) base::c(pref.matrix = "pref.matrix"), + if (!base::missing(directed)) base::c(directed = "directed"), + if (!base::missing(loops)) base::c(loops = "loops") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn sample_pref}.") + .arg_explicit <- base::c("n", "types", "type.dist", "fixed.sizes", "pref.matrix", "directed", "loops", "nodes")[base::pmatch(.arg_extra, base::c("n", "types", "type.dist", "fixed.sizes", "pref.matrix", "directed", "loops", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn sample_pref}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn sample_pref} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "sample_pref(nodes = )", "sample_pref(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("type.dist", "fixed.sizes", "pref.matrix", "directed", "loops"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `sample_pref()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: sample_pref(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("t", "ty", "typ", "type")) if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn sample_pref}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: sample_pref(nodes, types, type.dist, fixed.sizes, pref.matrix, directed, loops) @@ -2977,21 +3150,6 @@ sample_pref <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn sample_pref} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "sample_pref(nodes = )", - "sample_pref(n = )" - ) - n <- nodes - } - if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -3043,7 +3201,46 @@ pref <- function( ) { # BEGIN GENERATED ARG_HANDLE: pref, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: pref(nodes, types, type.dist, fixed.sizes, pref.matrix, directed, loops) + .old_signature <- function(nodes, types, type.dist, fixed.sizes, pref.matrix, directed, loops, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(types)) base::c(types = "types"), + if (!base::missing(type.dist)) base::c(type.dist = "type.dist"), + if (!base::missing(fixed.sizes)) base::c(fixed.sizes = "fixed.sizes"), + if (!base::missing(pref.matrix)) base::c(pref.matrix = "pref.matrix"), + if (!base::missing(directed)) base::c(directed = "directed"), + if (!base::missing(loops)) base::c(loops = "loops") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn pref}.") + .arg_explicit <- base::c("n", "types", "type.dist", "fixed.sizes", "pref.matrix", "directed", "loops", "nodes")[base::pmatch(.arg_extra, base::c("n", "types", "type.dist", "fixed.sizes", "pref.matrix", "directed", "loops", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn pref}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn pref} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "pref(nodes = )", "pref(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("type.dist", "fixed.sizes", "pref.matrix", "directed", "loops"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `pref()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: pref(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("t", "ty", "typ", "type")) if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn pref}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: pref(nodes, types, type.dist, fixed.sizes, pref.matrix, directed, loops) @@ -3091,21 +3288,6 @@ pref <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn pref} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "pref(nodes = )", - "pref(n = )" - ) - n <- nodes - } - if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -3139,7 +3321,44 @@ sample_asym_pref <- function( ) { # BEGIN GENERATED ARG_HANDLE: sample_asym_pref, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: sample_asym_pref(nodes, types, type.dist.matrix, pref.matrix, loops) + .old_signature <- function(nodes, types, type.dist.matrix, pref.matrix, loops, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(types)) base::c(types = "types"), + if (!base::missing(type.dist.matrix)) base::c(type.dist.matrix = "type.dist.matrix"), + if (!base::missing(pref.matrix)) base::c(pref.matrix = "pref.matrix"), + if (!base::missing(loops)) base::c(loops = "loops") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn sample_asym_pref}.") + .arg_explicit <- base::c("n", "types", "type.dist.matrix", "pref.matrix", "loops", "nodes")[base::pmatch(.arg_extra, base::c("n", "types", "type.dist.matrix", "pref.matrix", "loops", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn sample_asym_pref}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn sample_asym_pref} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "sample_asym_pref(nodes = )", "sample_asym_pref(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("type.dist.matrix", "pref.matrix", "loops"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `sample_asym_pref()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: sample_asym_pref(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("t", "ty", "typ", "type")) if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn sample_asym_pref}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: sample_asym_pref(nodes, types, type.dist.matrix, pref.matrix, loops) @@ -3183,21 +3402,6 @@ sample_asym_pref <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn sample_asym_pref} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "sample_asym_pref(nodes = )", - "sample_asym_pref(n = )" - ) - n <- nodes - } - if (is.null(type.dist.matrix)) { type.dist.matrix <- matrix(1, types, types) } @@ -3253,7 +3457,44 @@ asym_pref <- function( ) { # BEGIN GENERATED ARG_HANDLE: asym_pref, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: asym_pref(nodes, types, type.dist.matrix, pref.matrix, loops) + .old_signature <- function(nodes, types, type.dist.matrix, pref.matrix, loops, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(types)) base::c(types = "types"), + if (!base::missing(type.dist.matrix)) base::c(type.dist.matrix = "type.dist.matrix"), + if (!base::missing(pref.matrix)) base::c(pref.matrix = "pref.matrix"), + if (!base::missing(loops)) base::c(loops = "loops") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn asym_pref}.") + .arg_explicit <- base::c("n", "types", "type.dist.matrix", "pref.matrix", "loops", "nodes")[base::pmatch(.arg_extra, base::c("n", "types", "type.dist.matrix", "pref.matrix", "loops", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn asym_pref}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn asym_pref} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "asym_pref(nodes = )", "asym_pref(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("type.dist.matrix", "pref.matrix", "loops"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `asym_pref()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: asym_pref(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("t", "ty", "typ", "type")) if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn asym_pref}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: asym_pref(nodes, types, type.dist.matrix, pref.matrix, loops) @@ -3297,21 +3538,6 @@ asym_pref <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn asym_pref} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "asym_pref(nodes = )", - "asym_pref(n = )" - ) - n <- nodes - } - if (is.null(type.dist.matrix)) { type.dist.matrix <- matrix(1, types, types) } @@ -5343,7 +5569,44 @@ sample_forestfire <- function( ) { # BEGIN GENERATED ARG_HANDLE: sample_forestfire, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(nodes)) { + # Pre-3.0.0 signature: sample_forestfire(nodes, fw.prob, bw.factor, ambs, directed) + .old_signature <- function(nodes, fw.prob, bw.factor, ambs, directed, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(nodes)) base::c(n = "nodes"), + if (!base::missing(fw.prob)) base::c(fw.prob = "fw.prob"), + if (!base::missing(bw.factor)) base::c(bw.factor = "bw.factor"), + if (!base::missing(ambs)) base::c(ambs = "ambs"), + if (!base::missing(directed)) base::c(directed = "directed") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn sample_forestfire}.") + .arg_explicit <- base::c("n", "fw.prob", "bw.factor", "ambs", "directed", "nodes")[base::pmatch(.arg_extra, base::c("n", "fw.prob", "bw.factor", "ambs", "directed", "nodes"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn sample_forestfire}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn sample_forestfire} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(nodes)) lifecycle::deprecate_soft("3.0.0", "sample_forestfire(nodes = )", "sample_forestfire(n = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("bw.factor", "ambs", "directed"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `sample_forestfire()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: sample_forestfire(", base::paste(base::c("n", "fw.prob", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { # Pre-3.0.0 signature: sample_forestfire(nodes, fw.prob, bw.factor, ambs, directed) .old_signature <- function(bw.factor, ambs, directed, ...) { if (...length() > 0L) { @@ -5385,21 +5648,6 @@ sample_forestfire <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(nodes)) { - if (!missing(n)) { - cli::cli_abort(c( - "Argument {.arg n} of {.fn sample_forestfire} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg nodes}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "sample_forestfire(nodes = )", - "sample_forestfire(n = )" - ) - n <- nodes - } - res <- forest_fire_game_impl( nodes = n, fw_prob = fw.prob, diff --git a/tests/testthat/_snaps/games.md b/tests/testthat/_snaps/games.md index 67a3482f72..632e0d0508 100644 --- a/tests/testthat/_snaps/games.md +++ b/tests/testthat/_snaps/games.md @@ -108,7 +108,7 @@ # sample_grg() rejects `n` supplied both directly and as `nodes` Code - sample_grg(10, radius = 1, nodes = 10) + sample_grg(n = 10, radius = 1, nodes = 10) Condition Error in `sample_grg()`: ! Argument `n` of `sample_grg()` was supplied more than once. diff --git a/tests/testthat/test-games.R b/tests/testthat/test-games.R index a614f2a5d7..19ab37c96b 100644 --- a/tests/testthat/test-games.R +++ b/tests/testthat/test-games.R @@ -1783,11 +1783,22 @@ test_that("sample_grg(nodes = ) is deprecated but still works", { test_that("sample_grg() rejects `n` supplied both directly and as `nodes`", { rlang::local_options(lifecycle_verbosity = "warning") expect_snapshot( - sample_grg(10, radius = 1, nodes = 10), + sample_grg(n = 10, radius = 1, nodes = 10), error = TRUE ) }) +test_that("sample_grg(nodes = ) keeps the old order for positional values", { + # A call naming `nodes` was written against the old signature + # sample_grg(nodes, radius, torus, coords): a positional value fills the + # next old slot, not `n`. + igraph_local_seed(1) + expected <- sample_grg(10, 0.5, torus = TRUE) + igraph_local_seed(1) + lifecycle::expect_deprecated(g <- sample_grg(nodes = 10, 0.5, TRUE)) + expect_identical_graphs(g, expected) +}) + test_that("sample_pref(nodes = ) and sample_forestfire(nodes = ) are deprecated but still work", { igraph_local_seed(1) lifecycle::expect_deprecated( From 86d8789db105abef1c577f278406ee6798fcd350 Mon Sep 17 00:00:00 2001 From: David Schoch Date: Thu, 3 Dec 2026 15:35:27 +0100 Subject: [PATCH 5/5] chore: Regenerate the migration blocks Co-Authored-By: Claude Opus 5.5 --- R/centralization.R | 24 ++++++++++++++--- R/games.R | 66 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 75 insertions(+), 15 deletions(-) diff --git a/R/centralization.R b/R/centralization.R index 317cbb4c8c..5500a56577 100644 --- a/R/centralization.R +++ b/R/centralization.R @@ -533,10 +533,14 @@ centr_degree_tmax <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("mode", "loops"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `centr_degree_tmax()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: centr_degree_tmax(", base::paste(base::c("graph", "n", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: centr_degree_tmax(", base::paste(base::c("graph", "n", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: centr_degree_tmax(", base::paste(base::c("graph", "n", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -772,10 +776,14 @@ centr_betw_tmax <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("directed"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `centr_betw_tmax()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: centr_betw_tmax(", base::paste(base::c("graph", "n", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: centr_betw_tmax(", base::paste(base::c("graph", "n", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: centr_betw_tmax(", base::paste(base::c("graph", "n", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -979,10 +987,14 @@ centr_clo_tmax <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("mode"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `centr_clo_tmax()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: centr_clo_tmax(", base::paste(base::c("graph", "n", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: centr_clo_tmax(", base::paste(base::c("graph", "n", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: centr_clo_tmax(", base::paste(base::c("graph", "n", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -1172,10 +1184,14 @@ centr_eigen_tmax <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("directed", "scale"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `centr_eigen_tmax()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: centr_eigen_tmax(", base::paste(base::c("graph", "n", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: centr_eigen_tmax(", base::paste(base::c("graph", "n", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: centr_eigen_tmax(", base::paste(base::c("graph", "n", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { diff --git a/R/games.R b/R/games.R index e96517f1b0..826da734cd 100644 --- a/R/games.R +++ b/R/games.R @@ -2312,10 +2312,14 @@ sample_traits_callaway <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("edge.per.step", "type.dist", "pref.matrix", "directed"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `sample_traits_callaway()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: sample_traits_callaway(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: sample_traits_callaway(", base::paste(base::c("n", "types", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_traits_callaway(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -2441,10 +2445,14 @@ traits_callaway <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("edge.per.step", "type.dist", "pref.matrix", "directed"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `traits_callaway()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: traits_callaway(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: traits_callaway(", base::paste(base::c("n", "types", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: traits_callaway(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -2558,10 +2566,14 @@ sample_traits <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("type.dist", "pref.matrix", "directed"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `sample_traits()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: sample_traits(", base::paste(base::c("n", "types", "k", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: sample_traits(", base::paste(base::c("n", "types", "k", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_traits(", base::paste(base::c("n", "types", "k", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -2681,10 +2693,14 @@ traits <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("type.dist", "pref.matrix", "directed"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `traits()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: traits(", base::paste(base::c("n", "types", "k", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: traits(", base::paste(base::c("n", "types", "k", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: traits(", base::paste(base::c("n", "types", "k", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -2822,10 +2838,14 @@ sample_grg <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("torus", "coords"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `sample_grg()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: sample_grg(", base::paste(base::c("n", "radius", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: sample_grg(", base::paste(base::c("n", "radius", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_grg(", base::paste(base::c("n", "radius", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -2931,10 +2951,14 @@ grg <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("torus", "coords"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `grg()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: grg(", base::paste(base::c("n", "radius", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: grg(", base::paste(base::c("n", "radius", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: grg(", base::paste(base::c("n", "radius", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -3096,10 +3120,14 @@ sample_pref <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("type.dist", "fixed.sizes", "pref.matrix", "directed", "loops"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `sample_pref()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: sample_pref(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: sample_pref(", base::paste(base::c("n", "types", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_pref(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -3234,10 +3262,14 @@ pref <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("type.dist", "fixed.sizes", "pref.matrix", "directed", "loops"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `pref()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: pref(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: pref(", base::paste(base::c("n", "types", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: pref(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -3352,10 +3384,14 @@ sample_asym_pref <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("type.dist.matrix", "pref.matrix", "loops"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `sample_asym_pref()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: sample_asym_pref(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: sample_asym_pref(", base::paste(base::c("n", "types", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_asym_pref(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -3488,10 +3524,14 @@ asym_pref <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("type.dist.matrix", "pref.matrix", "loops"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `asym_pref()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: asym_pref(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: asym_pref(", base::paste(base::c("n", "types", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: asym_pref(", base::paste(base::c("n", "types", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -5600,10 +5640,14 @@ sample_forestfire <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("bw.factor", "ambs", "directed"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `sample_forestfire()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: sample_forestfire(", base::paste(base::c("n", "fw.prob", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: sample_forestfire(", base::paste(base::c("n", "fw.prob", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_forestfire(", base::paste(base::c("n", "fw.prob", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) {