Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: deprecation of scale param of eigen_centrality() #1527

Closed
wants to merge 12 commits into from
Closed
24 changes: 19 additions & 5 deletions R/centrality.R
Original file line number Diff line number Diff line change
Expand Up @@ -952,9 +952,8 @@ eigen_defaults <- function() {
#' @param graph Graph to be analyzed.
#' @param directed Logical scalar, whether to consider direction of the edges
#' in directed graphs. It is ignored for undirected graphs.
#' @param scale Logical scalar, whether to scale the result to have a maximum
#' score of one. If no scaling is used then the result vector has unit length
#' in the Euclidean norm.
#' @param scale `lifecycle::badge("deprecated")` The result is always scaled to have
#' a maximum score of one.
#' @param weights A numerical vector or `NULL`. This argument can be used
#' to give edge weights for calculating the weighted eigenvector centrality of
#' vertices. If this is `NULL` and the graph has a `weight` edge
Expand Down Expand Up @@ -990,7 +989,7 @@ eigen_defaults <- function() {
#' @cdocs igraph_eigenvector_centrality
eigen_centrality <- function(graph,
directed = FALSE,
scale = TRUE,
scale = deprecated(),
weights = NULL,
options = arpack_defaults()) {

Expand All @@ -1003,9 +1002,24 @@ eigen_centrality <- function(graph,
options <- options()
}

if (lifecycle::is_present(scale)) {
if (scale) {
lifecycle::deprecate_soft(
"2.1.1",
"eigen_centrality(scale)",
details = "eigen_centrality() will always behave as if scale=TRUE were used."
)
} else {
lifecycle::deprecate_warn(
"2.1.1",
"eigen_centrality(scale = 'always as if TRUE')",
details = "Normalization is always performed")
}
}

eigenvector_centrality_impl(graph = graph,
directed = directed,
scale = scale,
scale = TRUE,
weights = weights,
options = options)
}
Expand Down
7 changes: 3 additions & 4 deletions man/eigen_centrality.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/evcent.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 0 additions & 26 deletions tests/testthat/_snaps/authority.score.md

This file was deleted.

182 changes: 182 additions & 0 deletions tests/testthat/_snaps/centrality.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# eigen_centrality() deprecated scale argument

Code
eigen_centrality(g, scale = TRUE)
Condition
Warning:
The `scale` argument of `eigen_centrality()` is deprecated as of igraph 2.1.1.
i eigen_centrality() will always behave as if scale=TRUE were used.
Output
$vector
[1] 1 1 1 1 1 1 1 1 1 1

$value
[1] 2

$options
$options$bmat
[1] "I"

$options$n
[1] 10

$options$which
[1] "LA"

$options$nev
[1] 1

$options$tol
[1] 0

$options$ncv
[1] 0

$options$ldv
[1] 0

$options$ishift
[1] 1

$options$maxiter
[1] 3000

$options$nb
[1] 1

$options$mode
[1] 1

$options$start
[1] 1

$options$sigma
[1] 0

$options$sigmai
[1] 0

$options$info
[1] 0

$options$iter
[1] 1

$options$nconv
[1] 1

$options$numop
[1] 7

$options$numopb
[1] 0

$options$numreo
[1] 6



---

Code
eigen_centrality(g, scale = FALSE)
Condition
Warning:
The `scale` argument of `eigen_centrality()` always as if TRUE as of igraph 2.1.1.
i Normalization is always performed
Output
$vector
[1] 1 1 1 1 1 1 1 1 1 1

$value
[1] 2

$options
$options$bmat
[1] "I"

$options$n
[1] 10

$options$which
[1] "LA"

$options$nev
[1] 1

$options$tol
[1] 0

$options$ncv
[1] 0

$options$ldv
[1] 0

$options$ishift
[1] 1

$options$maxiter
[1] 3000

$options$nb
[1] 1

$options$mode
[1] 1

$options$start
[1] 1

$options$sigma
[1] 0

$options$sigmai
[1] 0

$options$info
[1] 0

$options$iter
[1] 1

$options$nconv
[1] 1

$options$numop
[1] 7

$options$numopb
[1] 0

$options$numreo
[1] 6



# `authority_score()` works

Code
s3 <- authority_score(g2, options = arpack_defaults)$vector
Condition
Warning:
`authority_score()` was deprecated in igraph 2.0.4.
i Please use `hits_scores()` instead.
Warning:
arpack_defaults was deprecated in igraph 1.6.0.
i Please use `arpack_defaults()` instead.
i So the function arpack_defaults(), not an object called arpack_defaults.

# `hub_score()` works

Code
s3 <- hub_score(g2, options = arpack_defaults)$vector
Condition
Warning:
`hub_score()` was deprecated in igraph 2.0.3.
i Please use `hits_scores()` instead.
Warning:
arpack_defaults was deprecated in igraph 1.6.0.
i Please use `arpack_defaults()` instead.
i So the function arpack_defaults(), not an object called arpack_defaults.

70 changes: 0 additions & 70 deletions tests/testthat/test-alpha.centrality.R

This file was deleted.

Loading
Loading