Skip to content

Commit fe3bb53

Browse files
committed
Silencing warnings during tests
1 parent 7c5c9a7 commit fe3bb53

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

tests/testthat/test-rewire.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,14 @@ test_that("When p=1 in rewiring, Pr(j'=i) = Pr(j'=k) for all (i,k) in V", {
6969

7070
# Simulating
7171
N <- 1e3
72-
out <- lapply(seq_len(N), function(y) {
73-
y <- rewire_graph(x, p=1.0, self = TRUE, undirected = FALSE, both.ends = FALSE,
74-
multiple = FALSE)
75-
y <- as.matrix(y)
76-
colSums(y)/sum(y)
72+
out <- suppressWarnings({
73+
lapply(seq_len(N), function(y) {
74+
y <- rewire_graph(
75+
x, p=1.0, self = TRUE, undirected = FALSE, both.ends = FALSE,
76+
multiple = FALSE)
77+
y <- as.matrix(y)
78+
colSums(y)/sum(y)
79+
})
7780
})
7881

7982
# # Computing the probability that an j was picked.

tests/testthat/test-struct_test.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ test_that("Methods of struct test", {
5353
x <- rdiffnet(100, 4, "central")
5454
diffnet.toa(x) <- sample(x$toa, nnodes(x))
5555

56-
ans1 <- struct_test(x, function(g) mean(threshold(g), na.rm = TRUE), 100)
57-
ans2 <- struct_test(x, function(g) mean(threshold(g), na.rm = TRUE), 100)
56+
ans1 <- suppressWarnings({
57+
struct_test(x, function(g) mean(threshold(g), na.rm = TRUE), 100)
58+
})
59+
ans2 <- suppressWarnings({
60+
struct_test(x, function(g) mean(threshold(g), na.rm = TRUE), 100)
61+
})
5862

5963
# pvalues of concatenated test should be the same no matter the order
6064
expect_equal(c(ans1,ans2)$p.value,c(ans2,ans1)$p.value)

0 commit comments

Comments
 (0)