From 3bb125fa858fba07448c6552c9978ad461b68f1c Mon Sep 17 00:00:00 2001 From: Jason Cory Brunson Date: Fri, 17 Jun 2022 11:05:54 -0400 Subject: [PATCH] rename simplex tree coercers to specify interfaces --- NAMESPACE | 22 ++++---- R/as-igraph.r | 2 +- R/as-py-gudhi.r | 24 ++++----- R/as-simplextree.r | 28 +++++----- cran-comments.md | 2 +- inst/examples/ex-as-py-gudhi.r | 12 ++--- inst/examples/ex-as-simplextree.r | 12 ++--- man/as_igraph.Rd | 3 ++ ...py_gudhi.Rd => as_py_gudhi_simplextree.Rd} | 38 +++++++------- ..._simplextree.Rd => as_rcpp_simplextree.Rd} | 51 +++++++++---------- tests/testthat/test-cmplx-list.r | 4 +- tests/testthat/test-igraph-class.r | 6 +-- tests/testthat/test-network-class.r | 6 +-- tests/testthat/test-py-gudhi.r | 2 +- tests/testthat/test-simplextree-class.r | 2 +- 15 files changed, 107 insertions(+), 107 deletions(-) rename man/{as_py_gudhi.Rd => as_py_gudhi_simplextree.Rd} (67%) rename man/{as_simplextree.Rd => as_rcpp_simplextree.Rd} (60%) diff --git a/NAMESPACE b/NAMESPACE index cf07d07..2fc26d2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,17 +15,17 @@ S3method(as_network,default) S3method(as_network,gudhi.simplex_tree.SimplexTree) S3method(as_network,igraph) S3method(as_network,network) -S3method(as_py_gudhi,Rcpp_SimplexTree) -S3method(as_py_gudhi,default) -S3method(as_py_gudhi,igraph) -S3method(as_py_gudhi,network) -S3method(as_simplextree,Rcpp_SimplexTree) -S3method(as_simplextree,default) -S3method(as_simplextree,gudhi.simplex_tree.SimplexTree) -S3method(as_simplextree,igraph) -S3method(as_simplextree,network) +S3method(as_py_gudhi_simplextree,Rcpp_SimplexTree) +S3method(as_py_gudhi_simplextree,default) +S3method(as_py_gudhi_simplextree,igraph) +S3method(as_py_gudhi_simplextree,network) +S3method(as_rcpp_simplextree,Rcpp_SimplexTree) +S3method(as_rcpp_simplextree,default) +S3method(as_rcpp_simplextree,gudhi.simplex_tree.SimplexTree) +S3method(as_rcpp_simplextree,igraph) +S3method(as_rcpp_simplextree,network) export(as_cmplx) export(as_igraph) export(as_network) -export(as_py_gudhi) -export(as_simplextree) +export(as_py_gudhi_simplextree) +export(as_rcpp_simplextree) diff --git a/R/as-igraph.r b/R/as-igraph.r index ae606a8..7b01095 100644 --- a/R/as-igraph.r +++ b/R/as-igraph.r @@ -65,7 +65,7 @@ as_igraph.Rcpp_SimplexTree <- function(x, index = NULL, ...) { res } -#' @rdname as_simplextree +#' @rdname as_igraph #' @export as_igraph.gudhi.simplex_tree.SimplexTree <- function(x, index = NULL, ...) { diff --git a/R/as-py-gudhi.r b/R/as-py-gudhi.r index 1093f21..1557ea4 100644 --- a/R/as-py-gudhi.r +++ b/R/as-py-gudhi.r @@ -5,8 +5,8 @@ #' #' @details #' -#' `as_py_gudhi()` is a generic function with specific methods for different -#' simplicial complex S3 classes. It returns an object of class +#' `as_py_gudhi_simplextree()` is a generic function with specific methods for +#' different simplicial complex S3 classes. It returns an object of class #' 'gudhi.simplex_tree.SimplexTree', which is a #' [reticulate][reticulate::reticulate] accessor to a Python object of class #' 'SimplexTree' implemented in GUDHI. @@ -23,11 +23,11 @@ #' @author Jason Cory Brunson #' @author Yara Skaf #' @export -as_py_gudhi <- function(x, ...) UseMethod("as_py_gudhi") +as_py_gudhi_simplextree <- function(x, ...) UseMethod("as_py_gudhi_simplextree") -#' @rdname as_py_gudhi +#' @rdname as_py_gudhi_simplextree #' @export -as_py_gudhi.default <- function(x, ...) { +as_py_gudhi_simplextree.default <- function(x, ...) { x <- ensure_cmplx(x) x <- ensure_list(x) # import GUDHI @@ -40,9 +40,9 @@ as_py_gudhi.default <- function(x, ...) { res } -#' @rdname as_py_gudhi +#' @rdname as_py_gudhi_simplextree #' @export -as_py_gudhi.Rcpp_SimplexTree <- function(x, ...) { +as_py_gudhi_simplextree.Rcpp_SimplexTree <- function(x, ...) { # import GUDHI gd <- reticulate::import("gudhi") @@ -68,9 +68,9 @@ as_py_gudhi.Rcpp_SimplexTree <- function(x, ...) { res } -#' @rdname as_py_gudhi +#' @rdname as_py_gudhi_simplextree #' @export -as_py_gudhi.igraph <- function(x, index = NULL, ...) { +as_py_gudhi_simplextree.igraph <- function(x, index = NULL, ...) { if (! is.null(index)) ensure_index(x, index) # import GUDHI gd <- reticulate::import("gudhi") @@ -91,13 +91,13 @@ as_py_gudhi.igraph <- function(x, index = NULL, ...) { res } -#' @rdname as_py_gudhi +#' @rdname as_py_gudhi_simplextree #' @export -as_py_gudhi.network <- function(x, index = NULL, ...) { +as_py_gudhi_simplextree.network <- function(x, index = NULL, ...) { # coerce to an igraph object x <- intergraph::asIgraph(x, ...) # invoke 'igraph' method - as_py_gudhi(x, index = index) + as_py_gudhi_simplextree(x, index = index) } diff --git a/R/as-simplextree.r b/R/as-simplextree.r index 435fb0a..2d340e7 100644 --- a/R/as-simplextree.r +++ b/R/as-simplextree.r @@ -5,8 +5,8 @@ #' #' @details #' -#' `as_simplextree()` is a generic function with specific methods for different -#' simplicial complex S3 classes. It returns an object of class +#' `as_rcpp_simplextree()` is a generic function with specific methods for +#' different simplicial complex S3 classes. It returns an object of class #' ['Rcpp_SimplexTree'][simplextree::Rcpp_SimplexTree], which is an [Rcpp #' Module][Rcpp::Module] that exposes an instance of a C++ instance of a simplex #' tree. @@ -21,11 +21,11 @@ #' 'Rcpp_SimplexTree'. #' @example inst/examples/ex-as-simplextree.r #' @export -as_simplextree <- function(x, ...) UseMethod("as_simplextree") +as_rcpp_simplextree <- function(x, ...) UseMethod("as_rcpp_simplextree") -#' @rdname as_simplextree +#' @rdname as_rcpp_simplextree #' @export -as_simplextree.default <- function(x, ...) { +as_rcpp_simplextree.default <- function(x, ...) { x <- ensure_cmplx(x) x <- ensure_list(x) @@ -35,13 +35,13 @@ as_simplextree.default <- function(x, ...) { res } -#' @rdname as_simplextree +#' @rdname as_rcpp_simplextree #' @export -as_simplextree.Rcpp_SimplexTree <- function(x, ...) x +as_rcpp_simplextree.Rcpp_SimplexTree <- function(x, ...) x -#' @rdname as_simplextree +#' @rdname as_rcpp_simplextree #' @export -as_simplextree.gudhi.simplex_tree.SimplexTree <- function(x, ...) { +as_rcpp_simplextree.gudhi.simplex_tree.SimplexTree <- function(x, ...) { # initialize simplex tree res <- simplextree::simplex_tree() @@ -51,9 +51,9 @@ as_simplextree.gudhi.simplex_tree.SimplexTree <- function(x, ...) { res } -#' @rdname as_simplextree +#' @rdname as_rcpp_simplextree #' @export -as_simplextree.igraph <- function(x, index = NULL, ...) { +as_rcpp_simplextree.igraph <- function(x, index = NULL, ...) { if (! is.null(index)) ensure_index(x, index) # generate vertex list @@ -75,13 +75,13 @@ as_simplextree.igraph <- function(x, index = NULL, ...) { res } -#' @rdname as_simplextree +#' @rdname as_rcpp_simplextree #' @export -as_simplextree.network <- function(x, index = NULL, ...) { +as_rcpp_simplextree.network <- function(x, index = NULL, ...) { # coerce to an igraph object x <- intergraph::asIgraph(x, ...) # invoke 'igraph' method - as_simplextree(x, index = index) + as_rcpp_simplextree(x, index = index) } diff --git a/cran-comments.md b/cran-comments.md index 16ea502..80cdd00 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -28,7 +28,7 @@ The check flagged the same spellings as the R-hub check. ## Version dependencies -The method `as_py_gudhi.Rcpp_SimplexTree()` operates differently depending on the version of {simplextree} installed. This has not been flagged by documentation and checks but may be important for the maintainers to know. +The method `as_py_gudhi_simplextree.Rcpp_SimplexTree()` operates differently depending on the version of {simplextree} installed. This has not been flagged by documentation and checks but may be important for the maintainers to know. ## Reverse dependencies diff --git a/inst/examples/ex-as-py-gudhi.r b/inst/examples/ex-as-py-gudhi.r index c5b8430..c4c3d50 100644 --- a/inst/examples/ex-as-py-gudhi.r +++ b/inst/examples/ex-as-py-gudhi.r @@ -16,21 +16,21 @@ rf <- TDA::ripsFiltration( maxdimension = 2L, maxscale = 1.7 ) print(rf$cmplx) -gd_rf <- as_py_gudhi(rf) +gd_rf <- as_py_gudhi_simplextree(rf) print_py_gudhi(gd_rf) -gd_rf2 <- as_py_gudhi(rf$cmplx) +gd_rf2 <- as_py_gudhi_simplextree(rf$cmplx) print_py_gudhi(gd_rf2) # convert a simplextree object st <- simplextree::simplex_tree() st$insert(list(3:5, 5:6, 8)) -gd_st <- as_py_gudhi(st) +gd_st <- as_py_gudhi_simplextree(st) print_py_gudhi(gd_st) # convert an igraph object ig <- igraph::graph(c(1,2, 2,3, 1,3, 3,4)) print(ig) -gd_ig <- as_py_gudhi(ig) +gd_ig <- as_py_gudhi_simplextree(ig) print_py_gudhi(gd_ig) # specify 0-simplex indices @@ -38,13 +38,13 @@ set.seed(0L) ig <- igraph::set_vertex_attr(ig, "id", value = sample(igraph::vcount(ig)) + 1L) igraph::V(ig)$id igraph::as_edgelist(ig) -gd_ig2 <- as_py_gudhi(ig, index = "id") +gd_ig2 <- as_py_gudhi_simplextree(ig, index = "id") print_py_gudhi(gd_ig2) # convert a network object el <- data.frame(tails = c(1, 2, 1, 3), heads = c(2, 3, 3, 4)) nw <- network::network.edgelist(el, network::network.initialize(4)) print(nw) -gd_nw <- as_py_gudhi(nw) +gd_nw <- as_py_gudhi_simplextree(nw) print_py_gudhi(gd_nw) } diff --git a/inst/examples/ex-as-simplextree.r b/inst/examples/ex-as-simplextree.r index 6ab5cbe..fe6a573 100644 --- a/inst/examples/ex-as-simplextree.r +++ b/inst/examples/ex-as-simplextree.r @@ -5,9 +5,9 @@ rf <- TDA::ripsFiltration( maxdimension = 2L, maxscale = 1.7 ) print(rf$cmplx) -st_rf <- as_simplextree(rf) +st_rf <- as_rcpp_simplextree(rf) print(st_rf) -st_rf2 <- as_simplextree(rf$cmplx) +st_rf2 <- as_rcpp_simplextree(rf$cmplx) print(st_rf2) \dontrun{ @@ -16,14 +16,14 @@ print(st_rf2) gd <- reticulate::import("gudhi") gd_st <- gd$SimplexTree() for (s in list(3:5, 5:6, 8)) gd_st$insert(as.list(s)) -st_gd <- as_simplextree(gd_st) +st_gd <- as_rcpp_simplextree(gd_st) st_gd$as_list() } # convert an igraph object ig <- igraph::graph(c(1,2, 2,3, 1,3, 3,4)) print(ig) -st_ig <- as_simplextree(ig) +st_ig <- as_rcpp_simplextree(ig) print(st_ig) # specify 0-simplex indices @@ -31,7 +31,7 @@ set.seed(0L) ig <- igraph::set_vertex_attr(ig, "id", value = sample(igraph::vcount(ig)) + 1L) igraph::V(ig)$id igraph::as_edgelist(ig) -st_ig <- as_simplextree(ig, index = "id") +st_ig <- as_rcpp_simplextree(ig, index = "id") st_ig$vertices st_ig$edges @@ -39,5 +39,5 @@ st_ig$edges el <- data.frame(tails = c(1, 2, 1, 3), heads = c(2, 3, 3, 4)) nw <- network::network.edgelist(el, network::network.initialize(4)) print(nw) -st_nw <- as_simplextree(nw) +st_nw <- as_rcpp_simplextree(nw) print(st_nw) diff --git a/man/as_igraph.Rd b/man/as_igraph.Rd index 3de2b77..2fe77fb 100644 --- a/man/as_igraph.Rd +++ b/man/as_igraph.Rd @@ -4,6 +4,7 @@ \alias{as_igraph} \alias{as_igraph.default} \alias{as_igraph.Rcpp_SimplexTree} +\alias{as_igraph.gudhi.simplex_tree.SimplexTree} \alias{as_igraph.igraph} \alias{as_igraph.network} \title{Coerce objects to class 'igraph'} @@ -14,6 +15,8 @@ as_igraph(x, ...) \method{as_igraph}{Rcpp_SimplexTree}(x, index = NULL, ...) +\method{as_igraph}{gudhi.simplex_tree.SimplexTree}(x, index = NULL, ...) + \method{as_igraph}{igraph}(x, ...) \method{as_igraph}{network}(x, ...) diff --git a/man/as_py_gudhi.Rd b/man/as_py_gudhi_simplextree.Rd similarity index 67% rename from man/as_py_gudhi.Rd rename to man/as_py_gudhi_simplextree.Rd index 6d12525..331e5ab 100644 --- a/man/as_py_gudhi.Rd +++ b/man/as_py_gudhi_simplextree.Rd @@ -1,22 +1,22 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/as-py-gudhi.r -\name{as_py_gudhi} -\alias{as_py_gudhi} -\alias{as_py_gudhi.default} -\alias{as_py_gudhi.Rcpp_SimplexTree} -\alias{as_py_gudhi.igraph} -\alias{as_py_gudhi.network} +\name{as_py_gudhi_simplextree} +\alias{as_py_gudhi_simplextree} +\alias{as_py_gudhi_simplextree.default} +\alias{as_py_gudhi_simplextree.Rcpp_SimplexTree} +\alias{as_py_gudhi_simplextree.igraph} +\alias{as_py_gudhi_simplextree.network} \title{Coerce objects to Python GUDHI simplex trees} \usage{ -as_py_gudhi(x, ...) +as_py_gudhi_simplextree(x, ...) -\method{as_py_gudhi}{default}(x, ...) +\method{as_py_gudhi_simplextree}{default}(x, ...) -\method{as_py_gudhi}{Rcpp_SimplexTree}(x, ...) +\method{as_py_gudhi_simplextree}{Rcpp_SimplexTree}(x, ...) -\method{as_py_gudhi}{igraph}(x, index = NULL, ...) +\method{as_py_gudhi_simplextree}{igraph}(x, index = NULL, ...) -\method{as_py_gudhi}{network}(x, index = NULL, ...) +\method{as_py_gudhi_simplextree}{network}(x, index = NULL, ...) } \arguments{ \item{x}{An R object to be coerced. See Details.} @@ -35,8 +35,8 @@ Coerce objects to 'SimplexTree' objects in Python GUDHI, accessed via \link[reticulate:reticulate]{the reticulate package}. } \details{ -\code{as_py_gudhi()} is a generic function with specific methods for different -simplicial complex S3 classes. It returns an object of class +\code{as_py_gudhi_simplextree()} is a generic function with specific methods for +different simplicial complex S3 classes. It returns an object of class 'gudhi.simplex_tree.SimplexTree', which is a \link[reticulate:reticulate]{reticulate} accessor to a Python object of class 'SimplexTree' implemented in GUDHI. @@ -60,21 +60,21 @@ rf <- TDA::ripsFiltration( maxdimension = 2L, maxscale = 1.7 ) print(rf$cmplx) -gd_rf <- as_py_gudhi(rf) +gd_rf <- as_py_gudhi_simplextree(rf) print_py_gudhi(gd_rf) -gd_rf2 <- as_py_gudhi(rf$cmplx) +gd_rf2 <- as_py_gudhi_simplextree(rf$cmplx) print_py_gudhi(gd_rf2) # convert a simplextree object st <- simplextree::simplex_tree() st$insert(list(3:5, 5:6, 8)) -gd_st <- as_py_gudhi(st) +gd_st <- as_py_gudhi_simplextree(st) print_py_gudhi(gd_st) # convert an igraph object ig <- igraph::graph(c(1,2, 2,3, 1,3, 3,4)) print(ig) -gd_ig <- as_py_gudhi(ig) +gd_ig <- as_py_gudhi_simplextree(ig) print_py_gudhi(gd_ig) # specify 0-simplex indices @@ -82,14 +82,14 @@ set.seed(0L) ig <- igraph::set_vertex_attr(ig, "id", value = sample(igraph::vcount(ig)) + 1L) igraph::V(ig)$id igraph::as_edgelist(ig) -gd_ig2 <- as_py_gudhi(ig, index = "id") +gd_ig2 <- as_py_gudhi_simplextree(ig, index = "id") print_py_gudhi(gd_ig2) # convert a network object el <- data.frame(tails = c(1, 2, 1, 3), heads = c(2, 3, 3, 4)) nw <- network::network.edgelist(el, network::network.initialize(4)) print(nw) -gd_nw <- as_py_gudhi(nw) +gd_nw <- as_py_gudhi_simplextree(nw) print_py_gudhi(gd_nw) } } diff --git a/man/as_simplextree.Rd b/man/as_rcpp_simplextree.Rd similarity index 60% rename from man/as_simplextree.Rd rename to man/as_rcpp_simplextree.Rd index ef9a5f6..316f2e7 100644 --- a/man/as_simplextree.Rd +++ b/man/as_rcpp_simplextree.Rd @@ -1,36 +1,33 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/as-igraph.r, R/as-simplextree.r -\name{as_igraph.gudhi.simplex_tree.SimplexTree} -\alias{as_igraph.gudhi.simplex_tree.SimplexTree} -\alias{as_simplextree} -\alias{as_simplextree.default} -\alias{as_simplextree.Rcpp_SimplexTree} -\alias{as_simplextree.gudhi.simplex_tree.SimplexTree} -\alias{as_simplextree.igraph} -\alias{as_simplextree.network} +% Please edit documentation in R/as-simplextree.r +\name{as_rcpp_simplextree} +\alias{as_rcpp_simplextree} +\alias{as_rcpp_simplextree.default} +\alias{as_rcpp_simplextree.Rcpp_SimplexTree} +\alias{as_rcpp_simplextree.gudhi.simplex_tree.SimplexTree} +\alias{as_rcpp_simplextree.igraph} +\alias{as_rcpp_simplextree.network} \title{Coerce objects to class 'Rcpp_SimplexTree'} \usage{ -\method{as_igraph}{gudhi.simplex_tree.SimplexTree}(x, index = NULL, ...) +as_rcpp_simplextree(x, ...) -as_simplextree(x, ...) +\method{as_rcpp_simplextree}{default}(x, ...) -\method{as_simplextree}{default}(x, ...) +\method{as_rcpp_simplextree}{Rcpp_SimplexTree}(x, ...) -\method{as_simplextree}{Rcpp_SimplexTree}(x, ...) +\method{as_rcpp_simplextree}{gudhi.simplex_tree.SimplexTree}(x, ...) -\method{as_simplextree}{gudhi.simplex_tree.SimplexTree}(x, ...) +\method{as_rcpp_simplextree}{igraph}(x, index = NULL, ...) -\method{as_simplextree}{igraph}(x, index = NULL, ...) - -\method{as_simplextree}{network}(x, index = NULL, ...) +\method{as_rcpp_simplextree}{network}(x, index = NULL, ...) } \arguments{ \item{x}{An R object to be coerced. See Details.} +\item{...}{Additional arguments passed to methods.} + \item{index}{Integer-valued vertex attribute to be used as 0-simplex indices. Ignored if \code{NULL} (the default).} - -\item{...}{Additional arguments passed to methods.} } \value{ An instance of a simplex tree, exposed as an Rcpp Module with class @@ -41,8 +38,8 @@ Coerce objects to 'Rcpp_SimplexTree' objects, as implemented in \link[simplextree:simplextree-package]{the simplextree package}. } \details{ -\code{as_simplextree()} is a generic function with specific methods for different -simplicial complex S3 classes. It returns an object of class +\code{as_rcpp_simplextree()} is a generic function with specific methods for +different simplicial complex S3 classes. It returns an object of class \link[simplextree:simplex_tree]{'Rcpp_SimplexTree'}, which is an \link[Rcpp:Module]{Rcpp Module} that exposes an instance of a C++ instance of a simplex tree. } @@ -54,9 +51,9 @@ rf <- TDA::ripsFiltration( maxdimension = 2L, maxscale = 1.7 ) print(rf$cmplx) -st_rf <- as_simplextree(rf) +st_rf <- as_rcpp_simplextree(rf) print(st_rf) -st_rf2 <- as_simplextree(rf$cmplx) +st_rf2 <- as_rcpp_simplextree(rf$cmplx) print(st_rf2) \dontrun{ @@ -65,14 +62,14 @@ print(st_rf2) gd <- reticulate::import("gudhi") gd_st <- gd$SimplexTree() for (s in list(3:5, 5:6, 8)) gd_st$insert(as.list(s)) -st_gd <- as_simplextree(gd_st) +st_gd <- as_rcpp_simplextree(gd_st) st_gd$as_list() } # convert an igraph object ig <- igraph::graph(c(1,2, 2,3, 1,3, 3,4)) print(ig) -st_ig <- as_simplextree(ig) +st_ig <- as_rcpp_simplextree(ig) print(st_ig) # specify 0-simplex indices @@ -80,7 +77,7 @@ set.seed(0L) ig <- igraph::set_vertex_attr(ig, "id", value = sample(igraph::vcount(ig)) + 1L) igraph::V(ig)$id igraph::as_edgelist(ig) -st_ig <- as_simplextree(ig, index = "id") +st_ig <- as_rcpp_simplextree(ig, index = "id") st_ig$vertices st_ig$edges @@ -88,6 +85,6 @@ st_ig$edges el <- data.frame(tails = c(1, 2, 1, 3), heads = c(2, 3, 3, 4)) nw <- network::network.edgelist(el, network::network.initialize(4)) print(nw) -st_nw <- as_simplextree(nw) +st_nw <- as_rcpp_simplextree(nw) print(st_nw) } diff --git a/tests/testthat/test-cmplx-list.r b/tests/testthat/test-cmplx-list.r index 0637979..7049308 100644 --- a/tests/testthat/test-cmplx-list.r +++ b/tests/testthat/test-cmplx-list.r @@ -27,14 +27,14 @@ test_that("list-to-'network' conversion preserves vertices", { test_that("list-to-'Rcpp_SimplexTree' conversion preserves 0,1-simplices", { skip_if_not_installed("simplextree") - st_rf <- as_simplextree(cp_rf) + st_rf <- as_rcpp_simplextree(cp_rf) expect_equal(cp_rf_vc, st_rf$n_simplices[[1L]]) expect_true(all(sort_el(cp_rf_el) == st_rf$edges)) }) test_that("list-to-GUDHI conversion preserves all simplices", { skip_if_not_installed("reticulate") - gd_rf <- as_py_gudhi(cp_rf) + gd_rf <- as_py_gudhi_simplextree(cp_rf) expect_equal(cp_rf_vc, gd_rf$num_vertices()) gd_sl <- reticulate::iterate(gd_rf$get_simplices(), function(s) s[[1L]]) expect_equal(sort_lst(gd_sl), sort_lst(cp_rf)) diff --git a/tests/testthat/test-igraph-class.r b/tests/testthat/test-igraph-class.r index 6bc06e4..1c793d4 100644 --- a/tests/testthat/test-igraph-class.r +++ b/tests/testthat/test-igraph-class.r @@ -15,14 +15,14 @@ test_that("'igraph'-to-'network' conversion preserves vertices", { test_that("'igraph'-to-'Rcpp_SimplexTree' conversion preserves 0,1-simplices", { skip_if_not_installed("simplextree") - st_kt <- as_simplextree(ig_kt) + st_kt <- as_rcpp_simplextree(ig_kt) expect_equal(igraph::gorder(ig_kt), st_kt$n_simplices[[1L]]) expect_true(all(ig_kt_el == st_kt$edges)) }) test_that("'igraph'-to-GUDHI conversion preserves 0,1-simplices", { skip_if_not_installed("reticulate") - gd_kt <- as_py_gudhi(ig_kt) + gd_kt <- as_py_gudhi_simplextree(ig_kt) expect_equal(igraph::gorder(ig_kt), gd_kt$num_vertices()) gd_el <- reticulate::iterate(gd_kt$get_skeleton(1L), function(s) s[[1L]]) gd_el <- sort_el(do.call(rbind, gd_el[sapply(gd_el, length) == 2L])) @@ -50,7 +50,7 @@ test_that("'igraph'-to-'network' conversion preserves attributes", { test_that("'igraph'-to-'Rcpp_SimplexTree' conversion uses indices", { skip_if_not_installed("simplextree") - st_kt <- as_simplextree(ig_kt, index = "id") + st_kt <- as_rcpp_simplextree(ig_kt, index = "id") ig_id <- igraph::vertex_attr(ig_kt, "id") expect_equal(sort(ig_id), st_kt$vertices) # reindex and sort edges by index diff --git a/tests/testthat/test-network-class.r b/tests/testthat/test-network-class.r index bbfa065..6e09736 100644 --- a/tests/testthat/test-network-class.r +++ b/tests/testthat/test-network-class.r @@ -15,14 +15,14 @@ test_that("'network'-to-'igraph' conversion preserves vertices", { test_that("'network'-to-'Rcpp_SimplexTree' conversion preserves 0,1-simplices", { skip_if_not_installed("simplextree") - st_flo <- as_simplextree(nw_flo) + st_flo <- as_rcpp_simplextree(nw_flo) expect_equal(network::network.size(nw_flo), st_flo$n_simplices[[1L]]) expect_true(all(nw_flo_el == st_flo$edges)) }) test_that("'network'-to-GUDHI conversion preserves 0,1-simplices", { skip_if_not_installed("reticulate") - gd_flo <- as_py_gudhi(nw_flo) + gd_flo <- as_py_gudhi_simplextree(nw_flo) expect_equal(network::network.size(nw_flo), gd_flo$num_vertices()) gd_el <- reticulate::iterate(gd_flo$get_skeleton(1L), function(s) s[[1L]]) gd_el <- sort_el(do.call(rbind, gd_el[sapply(gd_el, length) == 2L])) @@ -50,7 +50,7 @@ test_that("'network'-to-'igraph' conversion preserves attributes", { test_that("'network'-to-'Rcpp_SimplexTree' conversion uses indices", { skip_if_not_installed("simplextree") - st_flo <- as_simplextree(nw_flo, index = "id") + st_flo <- as_rcpp_simplextree(nw_flo, index = "id") nw_id <- network::get.vertex.attribute(nw_flo, "id") expect_equal(sort(nw_id), st_flo$vertices) # reindex and sort edges by index diff --git a/tests/testthat/test-py-gudhi.r b/tests/testthat/test-py-gudhi.r index 6e29613..b6c0b88 100644 --- a/tests/testthat/test-py-gudhi.r +++ b/tests/testthat/test-py-gudhi.r @@ -25,7 +25,7 @@ test_that("GUDHI-to-'network' conversion preserves vertices", { test_that("GUDHI-to-'Rcpp_SimplexTree' conversion preserves all simplices", { skip_if_not_installed("simplextree") - st_ex <- as_simplextree(gd_ex) + st_ex <- as_rcpp_simplextree(gd_ex) expect_equal(gd_ex$num_vertices(), st_ex$n_simplices[[1L]]) expect_identical( sort_lst(reticulate::iterate(gd_ex$get_simplices(), function(s) s[[1L]])), diff --git a/tests/testthat/test-simplextree-class.r b/tests/testthat/test-simplextree-class.r index f1e7023..a6869bb 100644 --- a/tests/testthat/test-simplextree-class.r +++ b/tests/testthat/test-simplextree-class.r @@ -29,7 +29,7 @@ test_that("'Rcpp_SimplexTree'-to-list conversion preserves 0,1-simplices", { test_that("'Rcpp_SimplexTree'-to-GUDHI conversion preserves all simplices", { skip_if_not_installed("reticulate") - gd_ex <- as_py_gudhi(st_ex) + gd_ex <- as_py_gudhi_simplextree(st_ex) expect_equal(length(st_ex$vertices), gd_ex$num_vertices()) gd_sl <- reticulate::iterate(gd_ex$get_simplices(), function(s) s[[1L]]) gd_sl <- sort_lst(gd_sl)