Skip to content

Commit

Permalink
fix: Fix compatibility layer for eccentricity() and radius() (#1394)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviator-app[bot] committed Jul 4, 2024
2 parents b356295 + 60e43c6 commit 7291118
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
14 changes: 2 additions & 12 deletions R/paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,13 @@ eccentricity <- function(graph, vids = V(graph), ..., weights = NULL, mode = c("
lifecycle::deprecate_soft(
"2.1.0",
"eccentricity(... =)",
details = "The arguments `weights` and `mode` must be named."
details = "The argument `mode` must be named."
)

rlang::check_dots_unnamed()

dots <- list(...)

if (is.null(weights) && length(dots) > 0) {
weights <- dots[[1]]
dots <- dots[-1]
}

if (missing(mode) && length(dots) > 0) {
mode <- dots[[1]]
}
Expand Down Expand Up @@ -313,18 +308,13 @@ radius <- function(graph, ..., weights = NULL, mode = c("all", "out", "in", "tot
lifecycle::deprecate_soft(
"2.1.0",
"radius(... =)",
details = "The arguments `weights` and `mode` must be named."
details = "The argument `mode` must be named."
)

rlang::check_dots_unnamed()

dots <- list(...)

if (is.null(weights) && length(dots) > 0) {
weights <- dots[[1]]
dots <- dots[-1]
}

if (missing(mode) && length(dots) > 0) {
mode <- dots[[1]]
}
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/_snaps/paths.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# radius() works -- lifecycle

Code
radius(g, NULL, "out")
radius(g, "out")
Condition
Warning:
The `...` argument of `radius()` is deprecated as of igraph 2.1.0.
i The arguments `weights` and `mode` must be named.
i The argument `mode` must be named.
Output
[1] 0

# eccentricity() works -- lifecycle

Code
eccentricity(g, vids = V(g), NULL, "out")
eccentricity(g, vids = V(g), "out")
Condition
Warning:
The `...` argument of `eccentricity()` is deprecated as of igraph 2.1.0.
i The arguments `weights` and `mode` must be named.
i The argument `mode` must be named.
Output
[1] 3 2 1 1 1 0 0 0 0 0

5 changes: 2 additions & 3 deletions tests/testthat/test-paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test_that("radius() works -- lifecycle", {
withr::local_seed(42)
g <- make_tree(10, 2)

expect_snapshot(radius(g, NULL, "out"))
expect_snapshot(radius(g, "out"))

})

Expand All @@ -44,8 +44,7 @@ test_that("eccentricity() works -- lifecycle", {
withr::local_seed(42)
g <- make_tree(10, 2)

expect_snapshot(eccentricity(g, vids = V(g), NULL, "out"))

expect_snapshot(eccentricity(g, vids = V(g), "out"))
})

test_that("graph_center() works", {
Expand Down

0 comments on commit 7291118

Please sign in to comment.