Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/assortativity.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ assortativity <- function(
if (!missing(directed)) {
dots[["directed"]] <- directed
}
if (missing(values)) {
if (is_missing(values)) {
dots[["types1"]] <- types1
} else {
dots[["types1"]] <- values
}
return(inject(assortativity_legacy(!!!dots)))
}

if (missing(values)) {
if (is_missing(values)) {
lifecycle::deprecate_warn(
"1.6.0",
"assortativity(types1 =)",
Expand Down
12 changes: 6 additions & 6 deletions R/attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ get.edge.attribute <- function(graph, name, index = E(graph)) {
graph_attr <- function(graph, name) {
ensure_igraph(graph)

if (missing(name)) {
if (is_missing(name)) {
return(graph.attributes(graph))
}

Expand Down Expand Up @@ -358,7 +358,7 @@ graph_attr <- function(graph, name) {
#' )
#' plot(g)
`graph_attr<-` <- function(graph, name, value) {
if (missing(name)) {
if (is_missing(name)) {
`graph.attributes<-`(graph, value)
} else {
check_string(name)
Expand Down Expand Up @@ -450,7 +450,7 @@ graph.attributes <- function(graph) {
#' plot(g)
vertex_attr <- function(graph, name, index = NULL) {
ensure_igraph(graph)
if (missing(name)) {
if (is_missing(name)) {
if (is.null(index)) {
return(vertex.attributes(graph))
}
Expand Down Expand Up @@ -504,7 +504,7 @@ vertex_attr <- function(graph, name, index = NULL) {
if (is.null(index)) {
index <- V(graph)
}
if (missing(name)) {
if (is_missing(name)) {
`vertex.attributes<-`(graph, index = index, value = value)
} else {
check_string(name)
Expand Down Expand Up @@ -774,7 +774,7 @@ set_value_at <- function(value, idx, length_out) {
edge_attr <- function(graph, name, index = NULL) {
ensure_igraph(graph)

if (missing(name)) {
if (is_missing(name)) {
if (is.null(index)) {
edge.attributes(graph)
} else {
Expand Down Expand Up @@ -829,7 +829,7 @@ edge_attr <- function(graph, name, index = NULL) {
if (is.null(index)) {
index <- E(graph)
}
if (missing(name)) {
if (is_missing(name)) {
`edge.attributes<-`(graph, index = index, value = value)
} else {
check_string(name)
Expand Down
8 changes: 4 additions & 4 deletions R/community.R
Original file line number Diff line number Diff line change
Expand Up @@ -1323,8 +1323,8 @@ cut_at <- function(communities, no, steps) {
}

if (
(!missing(no) && !missing(steps)) ||
(missing(no) && missing(steps))
(!is_missing(no) && !is_missing(steps)) ||
(is_missing(no) && is_missing(steps))
) {
cli::cli_abort("Please use either {.arg no} or {.arg steps} (but not both)")
}
Expand All @@ -1336,7 +1336,7 @@ cut_at <- function(communities, no, steps) {
# dedicated igraph_le_community_to_membership function.
if (isTRUE(communities$algorithm == "leading eigenvector")) {
n_initial <- max(communities$membership)
if (!missing(steps)) {
if (!is_missing(steps)) {
if (steps > nrow(mm)) {
cli::cli_warn("Cannot make that many steps.")
steps <- nrow(mm)
Expand All @@ -1360,7 +1360,7 @@ cut_at <- function(communities, no, steps) {
return(res$membership + 1L)
}

if (!missing(steps)) {
if (!is_missing(steps)) {
if (steps > nrow(mm)) {
cli::cli_warn("Cannot make that many steps.")
steps <- nrow(mm)
Expand Down
2 changes: 1 addition & 1 deletion R/flow.R
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ dominator_tree <- function(
# Argument checks
ensure_igraph(graph)

if (missing(root) || is.null(root)) {
if (is_missing(root) || is.null(root)) {
cli::cli_abort("{.arg root} must be specified.")
}
root <- as_igraph_vs(graph, root)
Expand Down
58 changes: 29 additions & 29 deletions R/indexing.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@
get_adjacency_submatrix <- function(x, i, j, attr = NULL) {
# If i or j is NULL, assume all nodes
# if not NULL make sure to handle duplicates correctly
if (missing(i)) {
if (is_missing(i)) {
i_seq <- seq_len(vcount(x))
has_i <- FALSE
} else {
i_seq <- i
has_i <- TRUE
}
if (missing(j)) {
if (is_missing(j)) {
j_seq <- seq_len(vcount(x))
has_j <- FALSE
} else {
Expand Down Expand Up @@ -220,20 +220,20 @@ get_adjacency_submatrix <- function(x, i, j, attr = NULL) {
################################################################
## Argument checks
if (
(!missing(from) || !missing(to)) &&
(!missing(i) || !missing(j))
(!is_missing(from) || !is_missing(to)) &&
(!is_missing(i) || !is_missing(j))
) {
cli::cli_abort(
"Cannot use {.arg from}/{.arg to} together with regular indices"
)
}
if (
(!missing(from) && missing(to)) ||
(missing(from) && !missing(to))
(!is_missing(from) && is_missing(to)) ||
(is_missing(from) && !is_missing(to))
) {
cli::cli_abort("Cannot use {.arg from}/{.arg to} without the other")
}
if (!missing(from)) {
if (!is_missing(from)) {
if ((!is.numeric(from) && !is.character(from)) || anyNA(from)) {
cli::cli_abort(
"{.arg from} must be a numeric or character vector without NAs"
Expand All @@ -251,7 +251,7 @@ get_adjacency_submatrix <- function(x, i, j, attr = NULL) {

##################################################################

if (!missing(from)) {
if (!is_missing(from)) {
res <- get_edge_ids(x, data.frame(from, to), error = FALSE)
if (edges) {
## nop
Expand All @@ -265,7 +265,7 @@ get_adjacency_submatrix <- function(x, i, j, attr = NULL) {
return(res)
}

if (missing(i) && missing(j)) {
if (is_missing(i) && is_missing(j)) {
return(as_adjacency_matrix(
x,
sparse = sparse,
Expand All @@ -278,7 +278,7 @@ get_adjacency_submatrix <- function(x, i, j, attr = NULL) {
i_has_dupes <- FALSE
j_has_dupes <- FALSE

if (!missing(i)) {
if (!is_missing(i)) {
i <- as_igraph_vs(x, i)
if (anyDuplicated(i)) {
i_has_dupes <- TRUE
Expand All @@ -287,7 +287,7 @@ get_adjacency_submatrix <- function(x, i, j, attr = NULL) {
i_map <- match(i_dupl, i)
}
}
if (!missing(j)) {
if (!is_missing(j)) {
j <- as_igraph_vs(x, j)
if (anyDuplicated(j)) {
j_has_dupes <- TRUE
Expand Down Expand Up @@ -382,29 +382,29 @@ get_adjacency_submatrix <- function(x, i, j, attr = NULL) {
) {
getfun <- if (edges) as_adj_edge_list else as_adj_list

if (!missing(i) && !missing(from)) {
if (!is_missing(i) && !is_missing(from)) {
cli::cli_abort("Cannot use both {.arg i} and {.arg from}")
}
if (!missing(j) && !missing(to)) {
if (!is_missing(j) && !is_missing(to)) {
cli::cli_abort("Cannot use both {.arg j} and {.arg to}")
}
if (missing(i) && !missing(from)) {
if (is_missing(i) && !is_missing(from)) {
i <- from
}
if (missing(j) && !missing(to)) {
if (is_missing(j) && !is_missing(to)) {
j <- to
}

directed_mode_in <-
if (missing(i) && missing(j)) {
if (is_missing(i) && is_missing(j)) {
getfun(x, mode = if (directed) "out" else "all")
} else if (missing(j)) {
} else if (is_missing(j)) {
if (!edges) {
adjacent_vertices(x, i, mode = if (directed) "out" else "all")
} else {
incident_edges(x, i, mode = if (directed) "out" else "all")
}
} else if (missing(i)) {
} else if (is_missing(i)) {
if (!edges) {
adjacent_vertices(x, j, mode = if (directed) "in" else "all")
} else {
Expand Down Expand Up @@ -469,16 +469,16 @@ expand.grid.unordered <- function(i, j, loops = FALSE, directed = FALSE) {
################################################################
## Argument checks
if (
(!missing(from) || !missing(to)) &&
(!missing(i) || !missing(j))
(!is_missing(from) || !is_missing(to)) &&
(!is_missing(i) || !is_missing(j))
) {
cli::cli_abort(
"Cannot use {.arg from}/{.arg to} together with regular indices"
)
}
if (
(!missing(from) && missing(to)) ||
(missing(from) && !missing(to))
(!is_missing(from) && is_missing(to)) ||
(is_missing(from) && !is_missing(to))
) {
cli::cli_abort("Cannot use {.arg from}/{.arg to} without the other")
}
Expand All @@ -491,7 +491,7 @@ expand.grid.unordered <- function(i, j, loops = FALSE, directed = FALSE) {
if (is.null(attr) && !is.null(value) && length(value) != 1) {
cli::cli_abort("Logical or numeric value must be of length 1")
}
if (!missing(from)) {
if (!is_missing(from)) {
if ((!is.numeric(from) && !is.character(from)) || anyNA(from)) {
cli::cli_abort(
"{.arg from} must be a numeric or character vector without NAs"
Expand All @@ -509,7 +509,7 @@ expand.grid.unordered <- function(i, j, loops = FALSE, directed = FALSE) {

##################################################################

if (!missing(from)) {
if (!is_missing(from)) {
if (
is.null(value) ||
(is.logical(value) && !value) ||
Expand All @@ -535,11 +535,11 @@ expand.grid.unordered <- function(i, j, loops = FALSE, directed = FALSE) {
(is.null(attr) && is.numeric(value) && value == 0)
) {
## Delete edges
if (missing(i) && missing(j)) {
if (is_missing(i) && is_missing(j)) {
todel <- seq_len(ecount(x))
} else if (missing(j)) {
} else if (is_missing(j)) {
todel <- unlist(incident_edges(x, v = i, mode = "out"))
} else if (missing(i)) {
} else if (is_missing(i)) {
todel <- unlist(incident_edges(x, v = j, mode = "in"))
} else {
edge_pairs <- expand.grid(i, j)
Expand All @@ -549,8 +549,8 @@ expand.grid.unordered <- function(i, j, loops = FALSE, directed = FALSE) {
x <- delete_edges(x, todel)
} else {
## Addition or update of an attribute (or both)
i <- if (missing(i)) as.numeric(V(x)) else as_igraph_vs(x, i)
j <- if (missing(j)) as.numeric(V(x)) else as_igraph_vs(x, j)
i <- if (is_missing(i)) as.numeric(V(x)) else as_igraph_vs(x, i)
j <- if (is_missing(j)) as.numeric(V(x)) else as_igraph_vs(x, j)
if (length(i) != 0 && length(j) != 0) {
edge_pairs <- expand.grid.unordered(
i,
Expand Down
16 changes: 8 additions & 8 deletions R/layout.R
Original file line number Diff line number Diff line change
Expand Up @@ -635,24 +635,24 @@ component_wise <- function(merge_method = "dla") {
normalize <- function(
xmin = -1,
xmax = 1,
ymin = NULL,
ymax = NULL,
zmin = NULL,
zmax = NULL
ymin,
ymax,
zmin,
zmax
) {
# NULL is a legal value here (norm_coords() skips normalization along an
# axis with a NULL limit), so the fallback to the x limits applies only
# when an argument is not supplied at all.
if (missing(ymin)) {
if (is_missing(ymin)) {
ymin <- xmin
}
if (missing(ymax)) {
if (is_missing(ymax)) {
ymax <- xmax
}
if (missing(zmin)) {
if (is_missing(zmin)) {
zmin <- xmin
}
if (missing(zmax)) {
if (is_missing(zmax)) {
zmax <- xmax
}

Expand Down
2 changes: 1 addition & 1 deletion R/operators.R
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ path <- function(...) {
#' @method - igraph
#' @export
`-.igraph` <- function(e1, e2) {
if (missing(e2)) {
if (is_missing(e2)) {
cli::cli_abort("Non-numeric argument to negation operator")
}
if (is_igraph(e2)) {
Expand Down
8 changes: 4 additions & 4 deletions R/par.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ igraph.options <- function(...) {
#' @inheritParams igraph_opt
#' @keywords internal
#' @export
getIgraphOpt <- function(x, default = NULL) {
getIgraphOpt <- function(x, default) {
# nocov start
lifecycle::deprecate_warn("2.0.0", "getIgraphOpt()", "igraph_opt()")

if (missing(default)) {
if (is_missing(default)) {
get_config(paste0("igraph::", x), .igraph.pars[[x]])
} else {
get_config(paste0("igraph::", x), default)
Expand Down Expand Up @@ -300,7 +300,7 @@ get_all_options <- function() {
igraph_opt <- function(
x,
...,
default = NULL
default
) {
# BEGIN GENERATED ARG_HANDLE: igraph_opt, do not edit, see tools/generate-migrations.R
# fmt: skip
Expand Down Expand Up @@ -337,7 +337,7 @@ igraph_opt <- function(
}
# END GENERATED ARG_HANDLE

if (missing(default)) {
if (is_missing(default)) {
get_config(paste0("igraph::", x), .igraph.pars[[x]])
} else {
get_config(paste0("igraph::", x), default)
Expand Down
4 changes: 2 additions & 2 deletions R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ print.igraph <- function(
vertex.attributes = NULL,
edge.attributes = NULL,
names = TRUE,
max.lines = NULL,
max.lines,
id = NULL,
...
) {
Expand All @@ -621,7 +621,7 @@ print.igraph <- function(
if (is.null(edge.attributes)) {
edge.attributes <- igraph_opt("print.edge.attributes")
}
if (missing(max.lines)) {
if (is_missing(max.lines)) {
# NULL is a legal value here (print all lines), so the option fallback
# applies only when the argument is not supplied at all.
max.lines <- igraph_opt("auto.print.lines")
Expand Down
Loading