Skip to content

Commit

Permalink
Correcting warning and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Nov 30, 2022
1 parent 666ad47 commit df68caa
Show file tree
Hide file tree
Showing 14 changed files with 214 additions and 55 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
Package: netdiffuseR
Title: Analysis of Diffusion and Contagion Processes on Networks
Version: 1.22.4
Version: 1.22.5
Authors@R: c(
person("George", "Vega Yon", email="[email protected]", role=c("aut", "cre"),
comment=c(ORCID = "0000-0002-3171-0844", what="Rewrite functions with Rcpp, plus new features")
Expand Down Expand Up @@ -50,7 50,7 @@ Suggests:
survival
VignetteBuilder: knitr
LinkingTo: Rcpp, RcppArmadillo
RoxygenNote: 7.2.1
RoxygenNote: 7.2.2
Encoding: UTF-8
URL: https://github.com/USCCANA/netdiffuseR,
https://USCCANA.github.io/netdiffuseR/
Expand Down
12 changes: 12 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 43,14 @@ S3method(ftable,diffnet_adopters)
S3method(hist,diffnet_bootnet)
S3method(hist,diffnet_struct_test)
S3method(image,diffnet_diffmap)
S3method(is_multiple,default)
S3method(is_multiple,diffnet)
S3method(is_self,default)
S3method(is_self,diffnet)
S3method(is_undirected,default)
S3method(is_undirected,diffnet)
S3method(is_valued,default)
S3method(is_valued,diffnet)
S3method(plot,diffnet)
S3method(plot,diffnet_adopters)
S3method(plot,diffnet_bass)
Expand Down Expand Up @@ -118,6 126,10 @@ export(hazard_rate)
export(igraph_to_diffnet)
export(igraph_vertex_rescale)
export(infection)
export(is_multiple)
export(is_self)
export(is_undirected)
export(is_valued)
export(isolated)
export(leader_matching)
export(matrix_compare)
Expand Down
13 changes: 12 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 1,19 @@
# Changes in netdiffuseR version 1.22.5 (2022-11-30)

* Solved warning and errors reported by CRAN before the package was archived.

* New S3 generic functions `is_self`, `is_multiple`, `is_valued`, and
`is_undirected` allow querying graph information for some methods.

* Fixed bug in `diag_expand`. Graphs with self ties were not transformed correctly
(diagonals were excluded.)


# Changes in netdiffuseR version 1.22.4 (2022-09-16)

* Replaced `getMethod("t"...)` by `t` responding to changes in the
`Matrix` package.


# Changes in netdiffuseR version 1.22.1 (2021-05-27)

Expand Down
3 changes: 2 additions & 1 deletion R/bass.r
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 61,8 @@
#'
#' @references
#' Bass's Basement Institute Institute. The Bass Model. (2010).
#' Available at: \url{http://www.bassbasement.org/BassModel/Default.aspx}. (Accessed: 29th March 2017)
#' Available at: \url{https://web.archive.org/web/20220331222618/http://www.bassbasement.org/BassModel/}.
#' (accessed live for the last time on March 29th, 2017.)
#' @name bass
#' @author George G. Vega Yon
#' @family statistics
Expand Down
75 changes: 75 additions & 0 deletions R/diffnet-methods.r
Original file line number Diff line number Diff line change
Expand Up @@ -1699,3 1699,78 @@ dim.diffnet <- function(x) {
as.integer(with(x$meta, c(n, k, nper)))
}

#' @rdname diffnet-class
#' @details The function `is_undirected` returns TRUE if the network is marked
#' as undirected. In the case of `diffnet` objects, this information is stored
#' in the `meta` element as `undirected`. The default method is to try to find
#' an attribute called `undirected`, i.e., `attr(x, "undirected")`, if no
#' attribute is found, then the function returns `FALSE`.
#'
#' The functions `is_self`, `is_valued`, and `is_multiple` work exactly the same
#' as `is_undirected`. `diffnet` networks are not valued.
#' @export
is_undirected <- function(x) UseMethod("is_undirected")

#' @export
#' @rdname diffnet-class
is_undirected.diffnet <- function(x) x$meta$undirected

#' @export
#' @rdname diffnet-class
is_undirected.default <- function(x) {
und <- attr(x, "undirected", exact = TRUE)
if (!length(und))
return(FALSE)
und
}

#' @export
#' @rdname diffnet-class
is_self <- function(x) UseMethod("is_self")

#' @export
#' @rdname diffnet-class
is_self.diffnet <- function(x) x$meta$self

#' @export
#' @rdname diffnet-class
is_self.default <- function(x) {
und <- attr(x, "self", exact = TRUE)
if (!length(und))
return(FALSE)
und
}

#' @export
#' @rdname diffnet-class
is_multiple <- function(x) UseMethod("is_multiple")

#' @export
#' @rdname diffnet-class
is_multiple.diffnet <- function(x) x$meta$multiple

#' @export
#' @rdname diffnet-class
is_multiple.default <- function(x) {
und <- attr(x, "multiple", exact = TRUE)
if (!length(und))
return(FALSE)
und
}

#' @export
#' @rdname diffnet-class
is_valued <- function(x) UseMethod("is_valued")

#' @export
#' @rdname diffnet-class
is_valued.diffnet <- function(x) return(FALSE)

#' @export
#' @rdname diffnet-class
is_valued.default <- function(x) {
und <- attr(x, "valued", exact = TRUE)
if (!length(und))
return(FALSE)
und
}
9 changes: 8 additions & 1 deletion R/random_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 176,14 @@ NULL

#' @export
#' @rdname rgraph_ba
rgraph_ba <- function(m0=1L, m=1L, t=10L, graph=NULL, self=TRUE, eta=NULL) {
rgraph_ba <- function(
m0 = 1L,
m = 1L,
t = 10L,
graph = NULL,
self = TRUE,
eta = NULL
) {

# Eta should be numeric vector
if (length(eta)) {
Expand Down
2 changes: 1 addition & 1 deletion R/rdiffnet.r
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 153,7 @@ rdiffnet_make_threshold <- function(x, n) {
}

rdiffnet_check_seed_graph <- function(seed.graph, rgraph.args, t, n) {

test <- class(seed.graph)

if ("function" %in% test) {
Expand Down Expand Up @@ -337,7 338,6 @@ rdiffnet <- function(
# Checking the class of the seed.graph
sgraph <- rdiffnet_check_seed_graph(seed.graph, rgraph.args, t, n)


# Checking baseline graph --------------------------------------------------
meta <- classify_graph(sgraph)

Expand Down
49 changes: 36 additions & 13 deletions R/spatial.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 20,12 @@
#' @export
diag_expand <- function(...) UseMethod("diag_expand")

.diag_expand <- function(graph, nper,
self=getOption("diffnet.self"),
valued=getOption("diffnet.valued")) {
.diag_expand <- function(
graph,
nper,
self = getOption("diffnet.self"),
valued = getOption("diffnet.valued")
) {

# Checking class
meta <- classify_graph(graph)
Expand Down Expand Up @@ -66,32 69,48 @@ diag_expand <- function(...) UseMethod("diag_expand")

#' @export
#' @rdname diag_expand
diag_expand.list <- function(graph, self=getOption("diffnet.self"),
valued=getOption("diffnet.valued"), ...) {
diag_expand.list <- function(
graph,
self = is_self(graph),
valued = is_valued(graph),
...
) {
.diag_expand(graph, length(graph), self, valued)
}


#' @export
#' @rdname diag_expand
diag_expand.diffnet <- function(graph, self=getOption("diffnet.self"),
valued=getOption("diffnet.valued"), ...) {
diag_expand.diffnet <- function(
graph,
self = is_self(graph),
valued = is_valued(graph),
...
) {
.diag_expand(graph$graph, graph$meta$nper, self, valued)
}

#' @export
#' @rdname diag_expand
diag_expand.matrix <- function(graph, nper, self=getOption("diffnet.self"),
valued=getOption("diffnet.valued"), ...) {
diag_expand.matrix <- function(
graph,
nper,
self = is_self(graph),
valued = is_valued(graph),
...) {

.diag_expand(list(methods::as(graph, "dgCMatrix")), nper, self, valued)
}


#' @export
#' @rdname diag_expand
diag_expand.array <- function(graph, self=getOption("diffnet.self"),
valued=getOption("diffnet.valued"), ...) {
diag_expand.array <- function(
graph,
self = is_self(graph),
valued = is_valued(graph),
...
) {

graph <- apply(graph, 3, function(x) methods::as(x, "dgCMatrix"))
diag_expand(graph, nslices(graph), self, valued)
Expand All @@ -100,8 119,12 @@ diag_expand.array <- function(graph, self=getOption("diffnet.self"),

#' @export
#' @rdname diag_expand
diag_expand.dgCMatrix <- function(graph, nper, self=getOption("diffnet.self"),
valued=getOption("diffnet.valued"), ...) {
diag_expand.dgCMatrix <- function(
graph,
nper,
self = is_self(graph),
valued = is_valued(graph),
...) {

.diag_expand(list(graph), nper, self, valued)
}
11 changes: 11 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 1,14 @@
Changes in netdiffuseR version 1.22.5 (2022-11-30)

- Solved warning and errors reported by CRAN before the package was
archived.

- New S3 generic functions is_self, is_multiple, is_valued, and
is_undirected allow querying graph information for some methods.

- Fixed bug in diag_expand. Graphs with self ties were not transformed
correctly (diagonals were excluded.)

Changes in netdiffuseR version 1.22.4 (2022-09-16)

- Replaced getMethod("t"...) by t responding to changes in the Matrix
Expand Down
3 changes: 2 additions & 1 deletion man/bass.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 5 additions & 32 deletions man/diag_expand.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit df68caa

Please sign in to comment.