Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
R-KenK committed Aug 12, 2021
2 parents 2c8f0eb + 21abd6b commit b9a752d
Show file tree
Hide file tree
Showing 61 changed files with 332 additions and 298 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: SimuNet
Title: Network simulation framework, with a zest of empiricism
Version: 2.1.0
Title: Network Simulation Framework, with a Zest of Empiricism
Version: 2.1.1
Authors@R:
person(given = "Kenneth",
family = "Keuk",
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ S3method(count_NA,scanList)
S3method(count_nonNA,empirical)
S3method(count_nonNA,sLlist)
S3method(count_nonNA,scanList)
S3method(print,edgeProb)
S3method(print,edgeProbMat)
S3method(print,matList)
S3method(print,scaled)
S3method(print,scanList)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SimuNet 2.1.1
* `print` method is cleaner for `edgeProb` and newly introduced `edgeProbMat` classes:
* `edgeProbMat` is the matrix itself stored in `edgeProb` object (their `$P`), with attribute
`Beta prior`

# SimuNet 2.1.0
* `print` methods are cleaner for SimuNet specific objects:
*`scanList` objects printing now relies on Matrix `sparseMatrix` class
Expand Down
1 change: 1 addition & 0 deletions R/edgeProb.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ draw_edgeProb <- function(Adj,samp.effort,
P[Adj.subfun(P)] <-
Adj[Adj.subfun(Adj)] |>
{\(x) stats::rbeta(length(x),shape1 = x + alpha.prior,shape2 = samp.effort - x + beta.prior)}()
class(P) <- c("edgeProbMat","weightedAdj")
attr(P,"Beta priors") <- c(alpha.prior,beta.prior)
P
}
Expand Down
30 changes: 27 additions & 3 deletions R/scanList_tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,32 @@ print.weightedAdj <- function(x,...) {
invisible(x)
}

#' Print method for `edgeProb` objects
#' @export
#' @noRd
print.edgeProb <- function(x,...) {
print(x$P)
invisible(x)
}

#' Print method for `edgeProbMat` objects
#' @export
#' @noRd
print.edgeProbMat <- function(x,digits = 3,...) {
to.print <- x |> round(digits = digits)
class(to.print) <- NULL
print_clean_scan(to.print,"Edge presence probability matrix",...)
format_attributes(x,...)
invisible(x)
}

#' Print method for `scaled` objects
#' @export
#' @noRd
print.scaled <- function(x,digits = 2,...) {
print.scaled <- function(x,digits = 3,...) {
to.print <- without_attrs(x) |> round(digits = digits)
class(to.print) <- NULL
print_clean_scan(to.print,"Weighted adjacency matrix",...)
print_clean_scan(to.print,"Scaled weighted adjacency matrix",...)
format_attributes(x,...)
invisible(x)
}
Expand Down Expand Up @@ -467,7 +486,8 @@ print_clean_scan <- function(scan,s,
col.names = FALSE,
note.dropping.colnames = FALSE,
...) {
cat("\nscan: ",s,sep = "")
if (is.numeric(s)) cat("\nscan: ",s,sep = "")
else cat("\n",s,sep = "")
methods::as(scan,"dgCMatrix") |>
Matrix::printSpMatrix(col.names = col.names,note.dropping.colnames = note.dropping.colnames,
...)
Expand All @@ -482,5 +502,9 @@ print_clean_scan <- function(scan,s,
#' @noRd
format_attributes <- function(x,...) {
if (!is.null(get_attrs(x))) cat("\n\nHidden attributes:",names(get_attrs(x)))
if (inherits(x,"edgeProbMat")) {
bet <- attr(x,"Beta priors")
cat("\n","alpha.prior =",bet[1],"-","beta.prior =",bet[2])
}
invisible(x)
}
2 changes: 1 addition & 1 deletion docs/404.html

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

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

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

2 changes: 1 addition & 1 deletion docs/articles/articles/SimuNet.html

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

2 changes: 1 addition & 1 deletion docs/articles/articles/bayesian_framework.html

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

2 changes: 1 addition & 1 deletion docs/articles/articles/experiments.html

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

Loading

0 comments on commit b9a752d

Please sign in to comment.