Skip to content

Commit

Permalink
Silencing warnings during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Sep 18, 2024
1 parent 7c5c9a7 commit fe3bb53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
13 changes: 8 additions & 5 deletions tests/testthat/test-rewire.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ test_that("When p=1 in rewiring, Pr(j'=i) = Pr(j'=k) for all (i,k) in V", {

# Simulating
N <- 1e3
out <- lapply(seq_len(N), function(y) {
y <- rewire_graph(x, p=1.0, self = TRUE, undirected = FALSE, both.ends = FALSE,
multiple = FALSE)
y <- as.matrix(y)
colSums(y)/sum(y)
out <- suppressWarnings({
lapply(seq_len(N), function(y) {
y <- rewire_graph(
x, p=1.0, self = TRUE, undirected = FALSE, both.ends = FALSE,
multiple = FALSE)
y <- as.matrix(y)
colSums(y)/sum(y)
})
})

# # Computing the probability that an j was picked.
Expand Down
8 changes: 6 additions & 2 deletions tests/testthat/test-struct_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ test_that("Methods of struct test", {
x <- rdiffnet(100, 4, "central")
diffnet.toa(x) <- sample(x$toa, nnodes(x))

ans1 <- struct_test(x, function(g) mean(threshold(g), na.rm = TRUE), 100)
ans2 <- struct_test(x, function(g) mean(threshold(g), na.rm = TRUE), 100)
ans1 <- suppressWarnings({
struct_test(x, function(g) mean(threshold(g), na.rm = TRUE), 100)
})
ans2 <- suppressWarnings({
struct_test(x, function(g) mean(threshold(g), na.rm = TRUE), 100)
})

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

0 comments on commit fe3bb53

Please sign in to comment.