Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 88c9777

Browse files
committedJun 17, 2022
add descriptions & details to coercer documentation
1 parent e32c028 commit 88c9777

21 files changed

+140
-81
lines changed
 

‎.Rbuildignore

+3
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@
1010
^LICENSE\.md$
1111
^.*\.Rproj$
1212
^\.Rproj\.user$
13+
14+
# R package
15+
^man-roxygen$
1316
^cran-comments\.md$
1417
^CRAN-SUBMISSION$

‎NAMESPACE

-5
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,25 @@ S3method(as_cmplx,default)
55
S3method(as_cmplx,gudhi.simplex_tree.SimplexTree)
66
S3method(as_cmplx,igraph)
77
S3method(as_cmplx,network)
8-
S3method(as_cmplx,simplextree)
98
S3method(as_igraph,Rcpp_SimplexTree)
109
S3method(as_igraph,default)
1110
S3method(as_igraph,gudhi.simplex_tree.SimplexTree)
1211
S3method(as_igraph,igraph)
1312
S3method(as_igraph,network)
14-
S3method(as_igraph,simplextree)
1513
S3method(as_network,Rcpp_SimplexTree)
1614
S3method(as_network,default)
1715
S3method(as_network,gudhi.simplex_tree.SimplexTree)
1816
S3method(as_network,igraph)
1917
S3method(as_network,network)
20-
S3method(as_network,simplextree)
2118
S3method(as_py_gudhi,Rcpp_SimplexTree)
2219
S3method(as_py_gudhi,default)
2320
S3method(as_py_gudhi,igraph)
2421
S3method(as_py_gudhi,network)
25-
S3method(as_py_gudhi,simplextree)
2622
S3method(as_simplextree,Rcpp_SimplexTree)
2723
S3method(as_simplextree,default)
2824
S3method(as_simplextree,gudhi.simplex_tree.SimplexTree)
2925
S3method(as_simplextree,igraph)
3026
S3method(as_simplextree,network)
31-
S3method(as_simplextree,simplextree)
3227
export(as_cmplx)
3328
export(as_igraph)
3429
export(as_network)

‎R/as-cmplx.r

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
#' @title Coerce objects to lists in the TDA package style
1+
#' @title Coerce objects to lists of simplices
2+
#'
3+
#' @description Coerce objects to lists of simplices, as used by
4+
#' [the TDA package][TDA::TDA-package].
5+
#'
6+
#' @details
7+
#'
8+
#' `as_cmplx()` is a generic function with specific methods for different
9+
#' simplicial complex S3 classes. It returns a list of integer vectors, each of
10+
#' which represents a simplex, and _all_ simplices are included in the list.
11+
#' When a filtration is constructed using `TDA::*Filtration()`, the first named
12+
#' element of the returned list, `cmplx`, is a list whose *i*th element
13+
#' contains the vertices of the *i*th simplex.
214
#'
3-
#' @description This generic function...
15+
#' @template sec-classes-methods
416
#'
517
#' @param x An R object to be coerced. See Details.
618
#' @param index Integer-valued vertex attribute to be used as 0-simplex indices.
@@ -28,12 +40,6 @@ as_cmplx.Rcpp_SimplexTree <- function(x, ...) {
2840
simplextree_list(x)
2941
}
3042

31-
#' @rdname as_cmplx
32-
#' @export
33-
as_cmplx.simplextree <- function(x, ...) {
34-
as_cmplx.Rcpp_SimplexTree(x, ...)
35-
}
36-
3743
#' @rdname as_cmplx
3844
#' @export
3945
as_cmplx.gudhi.simplex_tree.SimplexTree <- function(x, ...) {

‎R/as-igraph.r

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
#' @title Coerce objects to class 'igraph'
2-
#'
3-
#' @description This generic function...
4-
#'
2+
#'
3+
#' @description Coerce objects to 'igraph' objects, as implemented in
4+
#' [the igraph package][igraph::igraph-package].
5+
#'
6+
#' @details
7+
#'
8+
#' `as_igraph()` is a generic function with specific methods for different
9+
#' simplicial complex S3 classes. It returns an [igraph][igraph::igraph] object.
10+
#'
11+
#' @template sec-classes-methods
12+
#' @template to-graph
13+
#'
514
#' @param x An R object to be coerced. See Details.
615
#' @param index Character string to be added as a vertex attribute containing
716
#' 0-simplex indices. Ignored if `NULL` (the default).
@@ -56,12 +65,6 @@ as_igraph.Rcpp_SimplexTree <- function(x, index = NULL, ...) {
5665
res
5766
}
5867

59-
#' @rdname as_igraph
60-
#' @export
61-
as_igraph.simplextree <- function(x, index = NULL, ...) {
62-
as_igraph.Rcpp_SimplexTree(x, index = index, ...)
63-
}
64-
6568
#' @rdname as_simplextree
6669
#' @export
6770
as_igraph.gudhi.simplex_tree.SimplexTree <- function(x, index = NULL, ...) {

‎R/as-network.r

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
#' @title Coerce objects to class 'network'
22
#'
3-
#' @description This generic function...
3+
#' @description Coerce objects to 'network' objects, as implemented in
4+
#' [the network package][network::network-package].
5+
#'
6+
#' @details
7+
#'
8+
#' `as_network()` is a generic function with specific methods for different
9+
#' simplicial complex S3 classes. It returns a [network][network::network]
10+
#' object.
11+
#'
12+
#' @template sec-classes-methods
13+
#' @template to-graph
414
#'
515
#' @param x An R object to be coerced. See Details.
616
#' @param index Character string to be added as a vertex attribute containing
@@ -79,12 +89,6 @@ as_network.Rcpp_SimplexTree <- function(x, index = NULL, ...) {
7989
res
8090
}
8191

82-
#' @rdname as_network
83-
#' @export
84-
as_network.simplextree <- function(x, index = NULL, ...) {
85-
as_network.Rcpp_SimplexTree(x, index = index, ...)
86-
}
87-
8892
#' @rdname as_network
8993
#' @export
9094
as_network.gudhi.simplex_tree.SimplexTree <- function(x, index = NULL, ...) {

‎R/as-py-gudhi.r

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1-
#' @title Coerce objects to GUDHI simplex trees
2-
#'
3-
#' @description This generic function...
4-
#'
1+
#' @title Coerce objects to Python GUDHI simplex trees
2+
#'
3+
#' @description Coerce objects to 'SimplexTree' objects in Python GUDHI,
4+
#' accessed via [the reticulate package][reticulate::reticulate].
5+
#'
6+
#' @details
7+
#'
8+
#' `as_py_gudhi()` is a generic function with specific methods for different
9+
#' simplicial complex S3 classes. It returns an object of class
10+
#' 'gudhi.simplex_tree.SimplexTree', which is a
11+
#' [reticulate][reticulate::reticulate] accessor to a Python object of class
12+
#' 'SimplexTree' implemented in GUDHI.
13+
#'
14+
#' @template sec-classes-methods
15+
#'
516
#' @param x An R object to be coerced. See Details.
617
#' @param index Integer-valued vertex attribute to be used as 0-simplex indices.
718
#' Ignored if `NULL` (the default).
819
#' @param ... Additional arguments passed to methods.
9-
#' @return A list of integer vectors, each encoding one simplex.
20+
#' @return A simplex tree instantiated in Python GUDHI accessed through
21+
#' reticulate.
1022
#' @example inst/examples/ex-as-py-gudhi.r
1123
#' @author Jason Cory Brunson
1224
#' @author Yara Skaf
@@ -56,12 +68,6 @@ as_py_gudhi.Rcpp_SimplexTree <- function(x, ...) {
5668
res
5769
}
5870

59-
#' @rdname as_py_gudhi
60-
#' @export
61-
as_py_gudhi.simplextree <- function(x, ...) {
62-
as_py_gudhi.Rcpp_SimplexTree(x, ...)
63-
}
64-
6571
#' @rdname as_py_gudhi
6672
#' @export
6773
as_py_gudhi.igraph <- function(x, index = NULL, ...) {

‎R/as-simplextree.r

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
#' @title Coerce objects to class 'simplextree'
22
#'
3-
#' @description This generic function...
3+
#' @description Coerce objects to 'Rcpp_SimplexTree' objects, as implemented in
4+
#' [the simplextree package][simplextree::simplextree-package].
5+
#'
6+
#' @details
7+
#'
8+
#' `as_simplextree()` is a generic function with specific methods for different
9+
#' simplicial complex S3 classes. It returns an object of class
10+
#' ['Rcpp_SimplexTree'][simplextree::Rcpp_SimplexTree], which is an [Rcpp
11+
#' Module][Rcpp::Module] that exposes an instance of a C++ instance of a simplex
12+
#' tree.
13+
#'
14+
#' @template sec-classes-methods
415
#'
516
#' @param x An R object to be coerced. See Details.
617
#' @param index Integer-valued vertex attribute to be used as 0-simplex indices.
718
#' Ignored if `NULL` (the default).
819
#' @param ... Additional arguments passed to methods.
9-
#' @return An object of class 'simplextree'.
20+
#' @return An instance of a simplex tree, exposed as an Rcpp Module with class
21+
#' 'Rcpp_SimplexTree'.
1022
#' @example inst/examples/ex-as-simplextree.r
1123
#' @export
1224
as_simplextree <- function(x, ...) UseMethod("as_simplextree")
@@ -27,12 +39,6 @@ as_simplextree.default <- function(x, ...) {
2739
#' @export
2840
as_simplextree.Rcpp_SimplexTree <- function(x, ...) x
2941

30-
#' @rdname as_simplextree
31-
#' @export
32-
as_simplextree.simplextree <- function(x, ...) {
33-
as_simplextree.Rcpp_SimplexTree(x, ...)
34-
}
35-
3642
#' @rdname as_simplextree
3743
#' @export
3844
as_simplextree.gudhi.simplex_tree.SimplexTree <- function(x, ...) {

‎R/interplex-package.r

-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030
#' as implemented
3131
#' in [the network package][network::network-package]
3232

33-
#'
34-
#' When coercing from a simplicial complex structure to a graph structure,
35-
#' only the 1-skeleton is coerced; simplices of dimension > 1 are discarded
36-
#' and no warning is printed.
37-
3833
#' @docType package
3934
#' @name interplex
4035
NULL

‎inst/examples/ex-as-cmplx.r

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ cp_st <- as_cmplx(st)
1515
print(cp_st)
1616

1717
\dontrun{
18+
1819
# convert a Python GUDHI simplex tree
1920
gd <- reticulate::import("gudhi")
2021
gd_st <- gd$SimplexTree()

‎inst/examples/ex-as-igraph.r

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ig_st <- as_igraph(st)
1717
print(ig_st)
1818

1919
\dontrun{
20+
2021
# convert a Python GUDHI simplex tree
2122
gd <- reticulate::import("gudhi")
2223
gd_st <- gd$SimplexTree()

‎inst/examples/ex-as-network.r

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ nw_st <- as_network(st)
1717
print(nw_st)
1818

1919
\dontrun{
20+
2021
# convert a Python GUDHI simplex tree
2122
gd <- reticulate::import("gudhi")
2223
gd_st <- gd$SimplexTree()

‎inst/examples/ex-as-py-gudhi.r

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
\dontrun{
2+
23
# print GUDHI simplices
34
print_py_gudhi <- function(x) {
45
reticulate::iterate(

‎inst/examples/ex-as-simplextree.r

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ st_rf2 <- as_simplextree(rf$cmplx)
1111
print(st_rf2)
1212

1313
\dontrun{
14+
1415
# convert a Python GUDHI simplex tree
1516
gd <- reticulate::import("gudhi")
1617
gd_st <- gd$SimplexTree()

‎man-roxygen/sec-classes-methods.r

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#'
2+
#' The generic coercers recognize the following S3 classes during method
3+
#' dispatch: 'Rcpp_SimplexTree', 'gudhi.simplex_tree.SimplexTree', 'igraph', and
4+
#' 'network'. In case `x` matches none of these classes, the default method
5+
#' requires `x` to be a list of integer vectors representing simplices, or else
6+
#' a list with a named element `cmplx` having this structure, as used in
7+
#' [TDA::TDA-package].
8+
#'

‎man-roxygen/to-graph.r

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#'
2+
#' When coercing from a simplicial complex structure to a graph structure,
3+
#' only the 1-skeleton is coerced; simplices of dimension > 1 are discarded
4+
#' and no warning is printed.
5+
#'

‎man/as_cmplx.Rd

+12-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/as_igraph.Rd

+7-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/as_network.Rd

+8-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/as_py_gudhi.Rd

+13-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/as_simplextree.Rd

+11-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/interplex.Rd

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.