Skip to content

Commit

Permalink
test: refactor test-layout.fr.R for simplicity and readability (#1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviator-app[bot] authored Sep 17, 2024
2 parents dd7bfb3 + d566480 commit bbe1fa9
Show file tree
Hide file tree
Showing 13 changed files with 401 additions and 335 deletions.
51 changes: 29 additions & 22 deletions R/layout.R
Original file line number Diff line number Diff line change
Expand Up @@ -1189,8 +1189,9 @@ with_dh <- function(...) layout_spec(layout_with_dh, ...)
#' \sQuote{z} coordinates.
#' @param maxz Similar to `minx`, but gives the upper boundaries of the
#' \sQuote{z} coordinates.
#' @param coolexp,maxdelta,area,repulserad These arguments are not supported
#' from igraph version 0.8.0 and are ignored (with a warning).
#' @param coolexp,maxdelta,area,repulserad `r lifecycle::badge("deprecated")` These
#' arguments are not supported from igraph version 0.8.0 and are ignored
#' (with a warning).
#' @param maxiter A deprecated synonym of `niter`, for compatibility.
#' @return A two- or three-column matrix, each row giving the coordinates of a
#' vertex, according to the ids of the vertex ids.
Expand Down Expand Up @@ -1229,7 +1230,9 @@ layout_with_fr <- function(graph, coords = NULL, dim = 2,
grid = c("auto", "grid", "nogrid"), weights = NULL,
minx = NULL, maxx = NULL, miny = NULL, maxy = NULL,
minz = NULL, maxz = NULL,
coolexp, maxdelta, area, repulserad, maxiter) {
coolexp = deprecated(), maxdelta = deprecated(),
area = deprecated(), repulserad = deprecated(),
maxiter = deprecated()) {
# Argument checks
ensure_igraph(graph)
coords[] <- as.numeric(coords)
Expand Down Expand Up @@ -1265,17 +1268,17 @@ layout_with_fr <- function(graph, coords = NULL, dim = 2,
if (!is.null(maxy)) maxy <- as.numeric(maxy)
if (!is.null(minz)) minz <- as.numeric(minz)
if (!is.null(maxz)) maxz <- as.numeric(maxz)
if (!missing(coolexp)) {
warning("Argument `coolexp' is deprecated and has no effect")
if (lifecycle::is_present(coolexp)) {
lifecycle::deprecate_warn("0.8.0", "layout_with_fr(coolexp = )")
}
if (!missing(maxdelta)) {
warning("Argument `maxdelta' is deprecated and has no effect")
if (lifecycle::is_present(maxdelta)) {
lifecycle::deprecate_warn("0.8.0", "layout_with_fr(maxdelta = )")
}
if (!missing(area)) {
warning("Argument `area' is deprecated and has no effect")
if (lifecycle::is_present(area)) {
lifecycle::deprecate_warn("0.8.0", "layout_with_fr(area = )")
}
if (!missing(repulserad)) {
warning("Argument `repulserad' is deprecated and has no effect")
if (lifecycle::is_present(repulserad)) {
lifecycle::deprecate_warn("0.8.0", "layout_with_fr(repulserad = )")
}

on.exit(.Call(R_igraph_finalizer))
Expand Down Expand Up @@ -1503,8 +1506,8 @@ with_graphopt <- function(...) layout_spec(layout_with_graphopt, ...)
#' \sQuote{z} coordinates.
#' @param maxz Similar to `minx`, but gives the upper boundaries of the
#' \sQuote{z} coordinates.
#' @param niter,sigma,initemp,coolexp These arguments are not supported from
#' igraph version 0.8.0 and are ignored (with a warning).
#' @param niter,sigma,initemp,coolexp `r lifecycle::badge("deprecated")` These
#' arguments are not supported from igraph version 0.8.0 and are ignored (with a warning).
#' @param start Deprecated synonym for `coords`, for compatibility.
#' @return A numeric matrix with two (dim=2) or three (dim=3) columns, and as
#' many rows as the number of vertices, the x, y and potentially z coordinates
Expand All @@ -1528,7 +1531,11 @@ layout_with_kk <- function(graph, coords = NULL, dim = 2,
epsilon = 0.0, kkconst = max(vcount(graph), 1),
weights = NULL, minx = NULL, maxx = NULL,
miny = NULL, maxy = NULL, minz = NULL, maxz = NULL,
niter, sigma, initemp, coolexp, start) {
niter = deprecated(),
sigma = deprecated(),
initemp = deprecated(),
coolexp = deprecated(),
start = deprecated()) {
# Argument checks
if (!missing(coords) && !missing(start)) {
stop("Both `coords' and `start' are given, give only one of them.")
Expand Down Expand Up @@ -1560,17 +1567,17 @@ layout_with_kk <- function(graph, coords = NULL, dim = 2,
if (!is.null(minz)) minz <- as.numeric(minz)
if (!is.null(maxz)) maxz <- as.numeric(maxz)

if (!missing(niter)) {
warning("Argument `niter' is deprecated and has no effect")
if (lifecycle::is_present(niter)) {
lifecycle::deprecate_warn("0.8.0", "layout_with_kk(niter = )")
}
if (!missing(sigma)) {
warning("Argument `sigma' is deprecated and has no effect")
if (lifecycle::is_present(sigma)) {
lifecycle::deprecate_warn("0.8.0", "layout_with_kk(sigma = )")
}
if (!missing(initemp)) {
warning("Argument `initemp' is deprecated and has no effect")
if (lifecycle::is_present(initemp)) {
lifecycle::deprecate_warn("0.8.0", "layout_with_kk(initemp = )")
}
if (!missing(coolexp)) {
warning("Argument `coolexp' is deprecated and has no effect")
if (lifecycle::is_present(coolexp)) {
lifecycle::deprecate_warn("0.8.0", "layout_with_kk(coolexp = )")
}

on.exit(.Call(R_igraph_finalizer))
Expand Down
15 changes: 8 additions & 7 deletions man/layout_with_fr.Rd

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

14 changes: 7 additions & 7 deletions man/layout_with_kk.Rd

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

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

Code
l <- layout_with_fr(g, niter = 50, start.temp = sqrt(10) / 10, coolexp = 1,
maxdelta = 1, area = 1, repulserad = 1)
Condition
Warning:
The `coolexp` argument of `layout_with_fr()` is deprecated as of igraph 0.8.0.
Warning:
The `maxdelta` argument of `layout_with_fr()` is deprecated as of igraph 0.8.0.
Warning:
The `area` argument of `layout_with_fr()` is deprecated as of igraph 0.8.0.
Warning:
The `repulserad` argument of `layout_with_fr()` is deprecated as of igraph 0.8.0.

# layout_with_kk() deprecated arguments

Code
l <- layout_with_kk(g, maxiter = 50, coords = layout_in_circle(g), niter = 1,
sigma = 1, initemp = 1, coolexp = 1)
Condition
Warning:
The `niter` argument of `layout_with_kk()` is deprecated as of igraph 0.8.0.
Warning:
The `sigma` argument of `layout_with_kk()` is deprecated as of igraph 0.8.0.
Warning:
The `initemp` argument of `layout_with_kk()` is deprecated as of igraph 0.8.0.
Warning:
The `coolexp` argument of `layout_with_kk()` is deprecated as of igraph 0.8.0.

Loading

0 comments on commit bbe1fa9

Please sign in to comment.