Skip to content

Commit 7888fb3

Browse files
Need to import sparse constructor as well
1 parent fb51ff8 commit 7888fb3

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Generated by roxygen2: do not edit by hand
22

33
S3method(edgeList,SparseBlockMatrixR)
4+
S3method(sparse,SparseBlockMatrixR)
45
export(ccdr.run)
56
importFrom(Rcpp,sourceCpp)
67
importFrom(sparsebnUtils,edgeList)

R/s3-SparseBlockMatrixR.R

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ edgeList.SparseBlockMatrixR <- function(x){
265265
# sparse.SparseBlockMatrixR
266266
# 2016-01-22: Migrated to this file from s3-sparse.R
267267
#
268+
#' @export
268269
sparse.SparseBlockMatrixR <- function(x, index = "R", ...){
269270

270271
if(index != "R" && index != "C") stop("Invalid entry for index parameter: Must be either 'R' or 'C'!")
@@ -302,16 +303,16 @@ sparse.SparseBlockMatrixR <- function(x, index = "R", ...){
302303
}
303304
} # END SPARSE.SPARSEBLOCKMATRIXR
304305

305-
#------------------------------------------------------------------------------#
306-
# as.sparse.SparseBlockMatrixR
307-
# Convert FROM SparseBlockMatrixR TO sparse
308-
# By default, return the object using R indexing. If desired, the method can return C-style indexing by setting
309-
# index = "C".
310-
# 2016-01-22: Migrated to this file from s3-sparse.R
311-
#
312-
as.sparse.SparseBlockMatrixR <- function(x, index = "R", ...){
313-
sparse.SparseBlockMatrixR(x, index)
314-
} # END AS.SPARSE.SPARSEBLOCKMATRIXR
306+
# #------------------------------------------------------------------------------#
307+
# # as.sparse.SparseBlockMatrixR
308+
# # Convert FROM SparseBlockMatrixR TO sparse
309+
# # By default, return the object using R indexing. If desired, the method can return C-style indexing by setting
310+
# # index = "C".
311+
# # 2016-01-22: Migrated to this file from s3-sparse.R
312+
# #
313+
# as.sparse.SparseBlockMatrixR <- function(x, index = "R", ...){
314+
# sparse.SparseBlockMatrixR(x, index)
315+
# } # END AS.SPARSE.SPARSEBLOCKMATRIXR
315316

316317
# to_graphNEL.SparseBlockMatrixR
317318
# Convert SBM object to graphNEL object

R/zzz.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#' @importFrom sparsebnUtils num.edges
1616
#' @importFrom sparsebnUtils is.zero
1717
#' @importFrom sparsebnUtils edgeList
18+
#' @importFrom sparsebnUtils sparse
1819

1920
.onAttach <- function(libname, pkgname){
2021
### Only sparsebn needs a package startup message

tests/testthat/test-s3_as.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ test_that("as.sparse -> as.SparseBlockMatrixR -> as.sparse makes no changes", {
7777
m <- matrix(rep(0, 1), ncol = 1)
7878
sp <- sparsebnUtils::as.sparse(m)
7979
sbm <- suppressWarnings(sparsebnUtils::as.sparse(as.SparseBlockMatrixR(sp)))
80-
expect_that(sbm, equals(sp))
80+
expect_equivalent(sbm, sp)
8181

8282
m <- matrix(rep(0, 4), ncol = 2)
8383
sp <- sparsebnUtils::as.sparse(m)
8484
sbm <- suppressWarnings(sparsebnUtils::as.sparse(as.SparseBlockMatrixR(sp)))
85-
expect_that(sbm, equals(sp))
85+
expect_equivalent(sbm, sp)
8686

8787
### NOTE: Cannot test on random sparse matrix since SBM class ASSUMES a block structure,
8888
### i.e. induced by a DAG
@@ -91,7 +91,7 @@ test_that("as.sparse -> as.SparseBlockMatrixR -> as.sparse makes no changes", {
9191
m <- random.dag.matrix(10, 10)
9292
sp <- sparsebnUtils::as.sparse(m)
9393
sbm <- suppressWarnings(sparsebnUtils::as.sparse(as.SparseBlockMatrixR(sp)))
94-
expect_that(sbm, equals(sp))
94+
expect_equivalent(sbm, sp)
9595
})
9696

9797
### SparseBlockMatrixR -> edgeList -> matrix

0 commit comments

Comments
 (0)