Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions R/old-0_1_1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
oldsample_0_1_1 <- function() {
list(
3,
TRUE,
rep(c(0, 1, 2), each = 2L),
c(1, 2, 2, 0, 0, 1),
c(1, 0, 3, 2, 5, 4),
c(4, 3, 5, 0, 2, 1),
seq(0, 6, by = 2),
seq(0, 6, by = 2),
list(1, character(0), numeric(0)),
list(3, character(0), numeric(0)),
list(6, character(0), numeric(0))
) %>%
structure(class = "igraph")
}
19 changes: 19 additions & 0 deletions R/old-0_2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
oldsample_0_2 <- function() {
list(
3,
TRUE,
c(0, 1, 2),
c(1, 2, 0),
c(0, 1, 2),
c(2, 0, 1),
seq(0, 3, by = 1),
seq(0, 3, by = 1),
list(
c(1, 0),
list(),
list(bar = c("A", "B", "C")),
list(foo = c("a", "b", "c"))
)
) %>%
structure(class = "igraph")
}
20 changes: 20 additions & 0 deletions R/old-0_5.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
oldsample_0_5 <- function() {
list(
3,
TRUE,
c(0, 1, 2),
c(1, 2, 0),
c(0, 1, 2),
c(2, 0, 1),
seq(0, 3, by = 1),
seq(0, 3, by = 1),
list(
c(1, 0),
list() %>%
structure(names = character(0)),
list(bar = c("A", "B", "C")),
list(foo = c("a", "b", "c"))
)
) %>%
structure(class = "igraph")
}
19 changes: 19 additions & 0 deletions R/old-0_6.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
oldsample_0_6 <- function() {
list(
3,
TRUE,
c(0, 1, 2),
c(1, 2, 0),
c(0, 1, 2),
c(2, 0, 1),
seq(0, 3, by = 1),
seq(0, 3, by = 1),
list(
c(1, 0, 1),
list(name = "Ring graph", mutual = FALSE, circular = TRUE),
list(bar = c("A", "B", "C")),
list(foo = c("a", "b", "c"))
)
) %>%
structure(class = "igraph")
}
24 changes: 24 additions & 0 deletions R/old-1_0_0.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
oldsample_1_0_0 <- function() {
..env.1.. <- new.env(parent = baseenv())
..env.1..$me <- list(
3,
TRUE,
c(0, 1, 2),
c(1, 2, 0),
c(0, 1, 2),
c(2, 0, 1),
seq(0, 3, by = 1),
seq(0, 3, by = 1),
list(
c(1, 0, 1),
list(name = "Ring graph", mutual = FALSE, circular = TRUE),
list(bar = c("A", "B", "C")),
list(foo = c("a", "b", "c"))
),
..env.1..
) %>%
structure(class = "igraph")
..env.1..$.__igraph_version__. <- "0.8.0"
..env.1..$myid <- "0fb28c05-9cc1-4a24-ba62-f5c319a3051b"
..env.1..$me
}
28 changes: 28 additions & 0 deletions R/old-1_5_0.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
oldsample_1_5_0 <- function() {
..env.1.. <- new.env(parent = baseenv())
..env.1..$me <- list(
3,
TRUE,
c(0, 1, 2),
c(1, 2, 0),
NULL,
NULL,
NULL,
NULL,
list(
c(1, 0, 1),
list(name = "Ring graph", mutual = FALSE, circular = TRUE),
list(bar = c("A", "B", "C")),
list(foo = c("a", "b", "c"))
),
..env.1..
) %>%
structure(class = "igraph")

# This will be reconstructed on demand.
# ..env.1..$igraph <- constructive::.xptr("0x0")

..env.1..$.__igraph_version__. <- "1.5.0"
..env.1..$myid <- "0fb28c05-9cc1-4a24-ba62-f5c319a3051b"
..env.1..$me
}
21 changes: 17 additions & 4 deletions R/versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,24 @@ warn_version <- function(graph) {
stop("This graph was created by a new(er) igraph version. Please install the latest version of igraph and try again.")
}

oldformats <- function() {
readRDS(system.file("oldformats/oldformats.rds", package = "igraph"))
oldpredecessors <- function() {
c(
"1.5.0" = "1.4.3",
"1.0.0" = "0.7.1",
"0.6" = "0.5.5-4",
"0.5" = "0.4.5",
"0.2" = "0.1.2",
"0.1.1" = NA
)
}

oldsamples <- function() {
f <- oldformats()
rlang::set_names(f$result, f$version)
list(
"1.5.0" = oldsample_1_5_0(),
"1.0.0" = oldsample_1_0_0(),
"0.6" = oldsample_0_6(),
"0.5" = oldsample_0_5(),
"0.2" = oldsample_0_2(),
"0.1.1" = oldsample_0_1_1()
)
}
Binary file removed inst/oldformats/oldformats.rds
Binary file not shown.
14 changes: 3 additions & 11 deletions tests/testthat/_snaps/versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
This graph was created by a now unsupported old igraph version.
Call upgrade_version() before using igraph functions on that object.

---

Code
s[["0.4"]]
Error <simpleError>
This graph was created by a now unsupported old igraph version.
Call upgrade_version() before using igraph functions on that object.

---

Code
Expand All @@ -43,10 +35,10 @@
Code
s[["1.0.0"]]
Output
IGRAPH <myid> U--- 3 3 -- Ring graph
IGRAPH D--- 3 3 -- Ring graph
+ attr: name (g/c), mutual (g/l), circular (g/l), bar (v/c), foo (e/c)
+ edges from <myid>:
[1] 1--2 2--3 1--3
+ edges:
[1] 1->2 2->3 3->1

---

Expand Down
5 changes: 2 additions & 3 deletions tests/testthat/test-versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ test_that("we can upgrade from 0.4.0 to 0.8.0", {
})

test_that("reading of old igraph formats", {
local_igraph_options(print.id = FALSE)

s <- oldsamples()
expect_snapshot(error = TRUE, {
s[["0.1.1"]]
})
expect_snapshot(error = TRUE, {
s[["0.2"]]
})
expect_snapshot(error = TRUE, {
s[["0.4"]]
})
expect_snapshot(error = TRUE, {
s[["0.5"]]
})
Expand Down