Skip to content

Commit

Permalink
'networkLite' now depends on 'network' 1.19.0, and as_tibble.networkL…
Browse files Browse the repository at this point in the history
…ite() now always adds a "bipartite" attribute for consistency.
  • Loading branch information
krivit committed Nov 18, 2024
1 parent 08c0be5 commit 88d1f47
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ URL: https://github.com/EpiModel/networkLite/
BugReports: https://github.com/EpiModel/networkLite/issues
Depends:
R (>= 3.5),
network (>= 1.18.1)
network (>= 1.19.0)
Imports:
statnet.common (>= 4.11.0),
tibble,
Expand All @@ -35,4 +35,6 @@ Suggests:
RoxygenNote: 7.3.2.9000
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Remotes: github::statnet/statnet.common@master
Remotes:
github::statnet/statnet.common@master,
github::statnet/network@master
2 changes: 1 addition & 1 deletion R/matrix_conversions.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ as_tibble.networkLite <- function(x, attrnames = NULL, na.rm = TRUE, ...) {
out <- atomize(out, ...)
attr(out, "n") <- network.size(x)
attr(out, "vnames") <- network.vertex.names(x)
if (is.bipartite(x)) attr(out, "bipartite") <- x %n% "bipartite"
attr(out, "bipartite") <- NVL(x %n% "bipartite", FALSE)
out
}

Expand Down
6 changes: 0 additions & 6 deletions tests/testthat/test-networkLite.R
Original file line number Diff line number Diff line change
Expand Up @@ -548,13 +548,11 @@ test_that("more tibble tests", {
tbl <- as_tibble(nw, na.rm = FALSE)
tbl <- tbl[order(tbl$.tail, tbl$.head),]
class(tbl) <- c("edgelist", class(tbl))
attr(tbl, "n") <- network.size(nw)
nwL <- networkLite(tbl)
expect_error(expect_equiv_nets(nw, nwL))
expect_equal(list.edge.attributes(nwL), c("na"))

tbl <- as_tibble(nw, attrnames = "e1", na.rm = FALSE)
attr(tbl, "n") <- network.size(nw)
tbl <- tbl[order(tbl$.tail, tbl$.head),]
class(tbl) <- c("edgelist", class(tbl))
nwL <- networkLite(tbl)
Expand All @@ -564,23 +562,20 @@ test_that("more tibble tests", {
tbl <- as_tibble(nw, attrnames = c("e1", "e2"), na.rm = FALSE)
tbl <- tbl[order(tbl$.tail, tbl$.head),]
class(tbl) <- c("edgelist", class(tbl))
attr(tbl, "n") <- network.size(nw)
nwL <- networkLite(tbl)
expect_error(expect_equiv_nets(nw, nwL))
expect_equal(list.edge.attributes(nwL), c("e1", "e2", "na"))

tbl <- as_tibble(nw, attrnames = c("e1", "e2", "na"), na.rm = FALSE)
tbl <- tbl[order(tbl$.tail, tbl$.head),]
class(tbl) <- c("edgelist", class(tbl))
attr(tbl, "n") <- network.size(nw)
nwL <- networkLite(tbl)
expect_equiv_nets(nw, nwL)
expect_equal(list.edge.attributes(nwL), c("e1", "e2", "na"))

tbl <- as_tibble(nw, attrnames = c("e1", "e2", "na"), na.rm = TRUE)
tbl <- tbl[order(tbl$.tail, tbl$.head),]
class(tbl) <- c("edgelist", class(tbl))
attr(tbl, "n") <- network.size(nw)
nwL <- networkLite(tbl)
expect_error(expect_equiv_nets(nw, nwL))
expect_equal(list.edge.attributes(nwL), c("e1", "e2", "na"))
Expand Down Expand Up @@ -679,7 +674,6 @@ test_that("network and networkLite produce identical matrices, edgelists, and ti
as.edgelist(nwL, attrname = attrname, na.rm = na.rm, output = "tibble"))

tbl <- tibble::as_tibble(nw, attrname = attrname, na.rm = na.rm)
attr(tbl, "n") <- network.size(nw)
expect_identical(tbl,
tibble::as_tibble(nwL, attrname = attrname, na.rm = na.rm))
}
Expand Down

0 comments on commit 88d1f47

Please sign in to comment.