From 8ced78fe42d673f75bfb4318f358632a7377c942 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 24 Jul 2026 18:37:31 +0000 Subject: [PATCH] fix: use canonical structure() attribute names R-devel deprecates the special structure() arguments .Names, .Dim and .Dimnames, which emit warnings that the test suite escalates. Replace them with the canonical names, dim and dimnames in the affected test fixtures and one plot fixture. structure() maps both spellings to the same attributes, so the constructed objects are identical -- there is no behavior change. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_019E6CUgb5aFw6uvWXztcHgV --- R/plot.common.R | 2 +- tests/testthat/helper-test-functions.R | 6 +-- tests/testthat/test-attributes.R | 2 +- tests/testthat/test-centrality.R | 4 +- tests/testthat/test-community.R | 46 ++++++++++----------- tests/testthat/test-conversion.R | 8 ++-- tests/testthat/test-flow.R | 2 +- tests/testthat/test-indexing.R | 8 ++-- tests/testthat/test-make.R | 2 +- tests/testthat/test-structural-properties.R | 4 +- 10 files changed, 42 insertions(+), 42 deletions(-) diff --git a/R/plot.common.R b/R/plot.common.R index d5beec08456..70c903f534d 100644 --- a/R/plot.common.R +++ b/R/plot.common.R @@ -4841,7 +4841,7 @@ curve_multiple <- function(graph, start = 0.5) { 16777215L, 16777215L ), - .Dim = c(64L, 64L), + dim = c(64L, 64L), class = "nativeRaster", channels = 4L ) diff --git a/tests/testthat/helper-test-functions.R b/tests/testthat/helper-test-functions.R index 591ebf77c5a..94eae68ab9d 100644 --- a/tests/testthat/helper-test-functions.R +++ b/tests/testthat/helper-test-functions.R @@ -243,7 +243,7 @@ karate_oldstyle <- structure( Citation = "Wayne W. Zachary. An Information Flow Model for Conflict and Fission in Small Groups. Journal of Anthropological Research Vol. 33, No. 4 452-473", Author = "Wayne W. Zachary" ), - .Names = c("name", "Citation", "Author") + names = c("name", "Citation", "Author") ), structure( list( @@ -254,7 +254,7 @@ karate_oldstyle <- structure( ), name = karate_oldstyle_names ), - .Names = c("Faction", "name") + names = c("Faction", "name") ), structure( list( @@ -266,7 +266,7 @@ karate_oldstyle <- structure( 2, 7, 4, 2, 4, 2, 2, 4, 2, 3, 3, 4, 4, 5 ) ), - .Names = "weight" + names = "weight" ) ) ), diff --git a/tests/testthat/test-attributes.R b/tests/testthat/test-attributes.R index 62d07ef4a85..f46f03db367 100644 --- a/tests/testthat/test-attributes.R +++ b/tests/testthat/test-attributes.R @@ -71,7 +71,7 @@ test_that("bracketing works with shortcuts (not changing attribute of similar gr test_that("we can query all attributes at once", { g <- make_graph(c(1, 2, 1, 3, 2, 4)) - expect_equal(graph_attr(g), structure(list(), .Names = character(0))) + expect_equal(graph_attr(g), structure(list(), names = character(0))) expect_equal(unname(vertex_attr(g)), list()) expect_equal(unname(edge_attr(g)), list()) diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index 814b7c87adf..fc88d7a6122 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -573,7 +573,7 @@ test_that("eigen_centrality() works", { evc, structure( c(0.732, 0.732, 0.594, 1, 0.827, 0.594, 0.827, 0.407, 0.1, 0.023), - .Names = c("Andre", "Beverly", "Carol", "Diane", "Fernando", "Ed", "Garth", "Heather", "Ike", "Jane") + names = c("Andre", "Beverly", "Carol", "Diane", "Fernando", "Ed", "Garth", "Heather", "Ike", "Jane") ) ) @@ -857,7 +857,7 @@ test_that("arpack works for non-symmetric matrices", { 1, -4, 9, -2, 10, 1, -7, 7, 6, 7, -3, 0, 9, -5, -8, 1, -3, -3, -8, -7, -8, 10, 8, 7, 0, 6, -7, -8, 10, 10, 1, 0, -2, 6 ), - .Dim = c(10L, 10L) + dim = c(10L, 10L) ) f <- function(x, extra = NULL) A %*% x diff --git a/tests/testthat/test-community.R b/tests/testthat/test-community.R index 4c2be0281f2..2b147ae0bc4 100644 --- a/tests/testthat/test-community.R +++ b/tests/testthat/test-community.R @@ -100,8 +100,8 @@ test_that("communities function works", { `3` = c(9L, 10L, 15L, 16L, 19L, 21L, 23L, 27L, 30L, 31L, 33L, 34L), `4` = c(24L, 25L, 26L, 28L, 29L, 32L) ), - .Dim = 4L, - .Dimnames = list(c("1", "2", "3", "4")) + dim = 4L, + dimnames = list(c("1", "2", "3", "4")) ) ) @@ -116,8 +116,8 @@ test_that("communities function works", { `1` = letters[1:5], `2` = letters[6:10] ), - .Dim = 2L, - .Dimnames = list(c("1", "2")) + dim = 2L, + dimnames = list(c("1", "2")) ) ) }) @@ -249,10 +249,10 @@ test_that("cluster_leading_eigen works", { sizes(karate_lc), structure( c(7L, 12L, 9L, 6L), - .Dim = 4L, - .Dimnames = structure( + dim = 4L, + dimnames = structure( list(`Community sizes` = c("1", "2", "3", "4")), - .Names = "Community sizes" + names = "Community sizes" ), class = "table" ) @@ -421,10 +421,10 @@ test_that("cluster_leiden works", { sizes(karate_leiden), structure( c(17L, 17L), - .Dim = 2L, - .Dimnames = structure( + dim = 2L, + dimnames = structure( list(`Community sizes` = c("1", "2")), - .Names = "Community sizes" + names = "Community sizes" ), class = "table" ) @@ -445,10 +445,10 @@ test_that("cluster_leiden works", { sizes(karate_leiden_mod), structure( c(11L, 5L, 12L, 6L), - .Dim = 4L, - .Dimnames = structure( + dim = 4L, + dimnames = structure( list(`Community sizes` = c("1", "2", "3", "4")), - .Names = "Community sizes" + names = "Community sizes" ), class = "table" ) @@ -525,10 +525,10 @@ test_that("cluster_optimal works", { sizes(karate_optimal), structure( c(11L, 5L, 12L, 6L), - .Dim = 4L, - .Dimnames = structure( + dim = 4L, + dimnames = structure( list(`Community sizes` = c("1", "2", "3", "4")), - .Names = "Community sizes" + names = "Community sizes" ), class = "table" ) @@ -569,10 +569,10 @@ test_that("cluster_walktrap works", { sizes(karate_walktrap), structure( c(9L, 7L, 9L, 4L, 5L), - .Dim = 5L, - .Dimnames = structure( + dim = 5L, + dimnames = structure( list(`Community sizes` = c("1", "2", "3", "4", "5")), - .Names = "Community sizes" + names = "Community sizes" ), class = "table" ) @@ -608,8 +608,8 @@ test_that("groups works", { gr, structure( list(`1` = 1:10, `2` = 11:15), - .Dim = 2L, - .Dimnames = list(c("1", "2")) + dim = 2L, + dimnames = list(c("1", "2")) ) ) @@ -620,8 +620,8 @@ test_that("groups works", { gr, structure( list(`1` = letters[1:10], `2` = letters[11:15]), - .Dim = 2L, - .Dimnames = list(c("1", "2")) + dim = 2L, + dimnames = list(c("1", "2")) ) ) }) diff --git a/tests/testthat/test-conversion.R b/tests/testthat/test-conversion.R index 80d99042e26..c98b678fd5a 100644 --- a/tests/testthat/test-conversion.R +++ b/tests/testthat/test-conversion.R @@ -805,7 +805,7 @@ test_that("edge names work", { g2 <- delete_edges(g, c("b", "d", "e")) expect_equal( as_edgelist(g2), - structure(c(1, 3, 6, 7, 8, 9, 1, 2, 4, 7, 8, 9, 10, 10), .Dim = c(7L, 2L)) + structure(c(1, 3, 6, 7, 8, 9, 1, 2, 4, 7, 8, 9, 10, 10), dim = c(7L, 2L)) ) ## named vertices @@ -816,7 +816,7 @@ test_that("edge names work", { as_edgelist(g3), structure( c("c", "d", "e", "g", "h", "i", "a", "d", "e", "f", "h", "i", "j", "j"), - .Dim = c(7L, 2L) + dim = c(7L, 2L) ) ) @@ -825,7 +825,7 @@ test_that("edge names work", { g4 <- delete_edges(g, c("1|2", "8|7", "1|10")) expect_equal( as_edgelist(g4), - structure(c(2, 3, 4, 5, 6, 8, 9, 3, 4, 5, 6, 7, 9, 10), .Dim = c(7L, 2L)) + structure(c(2, 3, 4, 5, 6, 8, 9, 3, 4, 5, 6, 7, 9, 10), dim = c(7L, 2L)) ) ## mix edge names and vertex names @@ -837,7 +837,7 @@ test_that("edge names work", { as_edgelist(g5), structure( c("b", "c", "d", "e", "g", "h", "a", "c", "d", "e", "f", "h", "i", "j"), - .Dim = c(7L, 2L) + dim = c(7L, 2L) ) ) }) diff --git a/tests/testthat/test-flow.R b/tests/testthat/test-flow.R index d9bf184056b..0370c238d4f 100644 --- a/tests/testthat/test-flow.R +++ b/tests/testthat/test-flow.R @@ -271,7 +271,7 @@ test_that("dominator_tree works -- legacy", { as_edgelist(dtree$domtree), structure( c("R", "R", "R", "R", "R", "C", "C", "D", "R", "R", "G", "R", "A", "B", "C", "D", "E", "F", "G", "L", "H", "I", "J", "K"), - .Dim = c(12L, 2L) + dim = c(12L, 2L) ) ) }) diff --git a/tests/testthat/test-indexing.R b/tests/testthat/test-indexing.R index 7aa9598f3c5..9dc75f54d28 100644 --- a/tests/testthat/test-indexing.R +++ b/tests/testthat/test-indexing.R @@ -54,8 +54,8 @@ test_that("[ indexing works with logical vectors", { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), - .Dim = c(2L, 20L), - .Dimnames = list( + dim = c(2L, 20L), + dimnames = list( c("b", "c"), c( "a", "b", "c", @@ -77,8 +77,8 @@ test_that("[ indexing works with negative indices", { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), - .Dim = c(2L, 19L), - .Dimnames = list( + dim = c(2L, 19L), + dimnames = list( c("b", "c"), c( "b", "c", "d", "e", "f", "g", "h", "i", "j", diff --git a/tests/testthat/test-make.R b/tests/testthat/test-make.R index dac0dd6d383..83552744f20 100644 --- a/tests/testthat/test-make.R +++ b/tests/testthat/test-make.R @@ -440,7 +440,7 @@ test_that("make_kautz_graph works", { 20, 21, 22, 23, 24, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ), - .Dim = c(48L, 2L) + dim = c(48L, 2L) ) ) }) diff --git a/tests/testthat/test-structural-properties.R b/tests/testthat/test-structural-properties.R index dfdf3fcb231..664d1337889 100644 --- a/tests/testthat/test-structural-properties.R +++ b/tests/testthat/test-structural-properties.R @@ -513,7 +513,7 @@ test_that("transitivity() works", { t33 <- transitivity(g, type = "local") est3 <- structure( c(0, 0.06667, 0.1028, 0.1016, 0.1333, 0.2222), - .Names = c( + names = c( "Min.", "1st Qu.", "Median", @@ -1058,7 +1058,7 @@ test_that("knn works", { knn = c(1, rep(9, 9)), knnk = c(9, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 1) ), - .Names = c("knn", "knnk") + names = c("knn", "knnk") ) ) })