Skip to content

Commit 02f19ca

Browse files
authored
fix bug when save = FALSE & egde_prior = "Stochastic-Block" (#36)
* fix bug when save = FALSE & egde_prior = "Stochastic-Block" * update: changed name of argument
1 parent 73ae38d commit 02f19ca

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

R/bgm.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ bgm = function(x,
544544
thresholds = thresholds, allocations = out$allocations,
545545
arguments = arguments)
546546
class(output) = "bgms"
547-
summary_Sbm = summarySBM(output)
547+
summary_Sbm = summarySBM(output,
548+
internal_call = TRUE)
548549

549550
output$components = summary_Sbm$components
550551
output$allocations = summary_Sbm$allocations

R/posterior_utils.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ compute_p_k_given_t = function(
9292
#' number of clusters.
9393
#'
9494
#' @param bgm_object A fit object created by the bgm function.
95+
#' @param internal_call A logical value indicating whether the function is used
96+
#' within bgms for calculating the posterior probabilities of the number of
97+
#' clusters or by the user. This argument is always set to FALSE.
9598
#' @return Returns a list of two elements: \code{components} and \code{allocations},
9699
#' containing the posterior probabilities for the number of components (clusters)
97100
#' and the estimated cluster allocation of the nodes using Dahl's method.
@@ -107,14 +110,15 @@ compute_p_k_given_t = function(
107110
#' }
108111
#' @export
109112
summarySBM = function(
110-
bgm_object) {
113+
bgm_object,
114+
internal_call = FALSE) {
111115

112116
arguments = extract_arguments(bgm_object)
113117

114118
if(arguments$edge_prior != "Stochastic-Block")
115119
stop('The bgm function must be run with edge_prior = "Stochastic-Block".')
116120

117-
if(arguments$save == FALSE)
121+
if(arguments$save == FALSE && internal_call == FALSE)
118122
stop('The bgm function must be run with save = TRUE.')
119123

120124
cluster_allocations = bgm_object$allocations

man/bgms-package.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/summarySBM.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)