Graph-level prior samplers and a progress bar for the correction-table build#161
Merged
Conversation
sample_graph_prior() draws edge indicators and edge-prior hyperparameters from the graph level of the spike-and-slab prior. The hierarchical specification samples ancestrally (hyperparameters from their prior, then independent pair flips), which is exact. The joint specification runs the zero-data prior chain and discards the precision draws, so the returned graphs carry the per-graph normalizer tilt and the hyperparameter updates apply the normalizing-constant correction. Hyperparameters can be fixed instead of sampled: theta for Bernoulli and Beta-Bernoulli priors, allocations plus block_probs for the Stochastic-Block prior. sample_sbm_prior() draws block allocations and pair-inclusion probabilities ancestrally from the MFM-SBM hyperprior, wrapping the internal helpers that until now only initialized the joint chain. The correction-table build message printed before the cache check, so every fit read 'building or loading' even when the table loaded instantly. The message now prints only on an actual build, states that the build is one-time and cached, and the sweep reports progress: a progress bar on one core, a cell-and-core count when parallel. Stage 1 of the prior-sampler redesign (dev/plans/active/2026-07-06_prior-sampler-redesign_DESIGN.md).
Gate the build progress bar on display_progress (the sampler's own control) instead of bgms.verbose, and draw it for both serial and parallel builds; a parallel build advances the bar as each batch of forked chains completes. The build announcement stays on bgms.verbose. Remove the top-level options(bgms.verbose = FALSE) from helper-fixtures.R so devtools::load_all no longer silences fit-time output in development sessions; setup.R still quiets the test run. Document the cores contract in bgm(): sampling uses min(cores, chains), while computations outside sampling (the correction-table build) use all cores.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #161 +/- ##
===========================================
- Coverage 91.13% 91.05% -0.08%
===========================================
Files 103 104 +1
Lines 14515 14748 +233
===========================================
+ Hits 13228 13429 +201
- Misses 1287 1319 +32 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
Two new functions for drawing from the graph level of the edge-selection prior, and a cleaner experience when a fit has to build the correction table.
New functions
sample_graph_prior()— draws edge-inclusion indicators, and any edge-prior hyperparameters, directly from the prior. Exact draws under the hierarchical specification; a zero-data prior chain under the joint specification.sample_sbm_prior()— draws block memberships and pair-inclusion probabilities from the stochastic-block edge prior.Correction-table build experience
display_progress, so it shows up whenever the sampling bar would.bgm()'scoresargument now documents this: sampling usesmin(cores, chains), while the correction-table build uses allcores.Fix
bgms.verbose = FALSEat load time, which silenced messages and progress bars in sessions loaded withdevtools::load_all(). Moved to the test setup only, so it no longer leaks into interactive use.Testing
R CMD check --as-cranclean apart from the usual environmental notes.