Skip to content

Fix validate_undirected_sbm() check and print.undirected_sbm() output - #73

Draft
alexpghayes wants to merge 1 commit into
mainfrom
fix/sbm-validator-print
Draft

alexpghayes wants to merge 1 commit into
mainfrom
fix/sbm-validator-print

Conversation

@alexpghayes

Copy link
Copy Markdown
Collaborator

Bugs

  • validate_undirected_sbm() could never fire. if (any(distinct_theta_by_block) > 1) (R/undirected_sbm.R:16) compares a logical with 1, so it was always FALSE, and an SBM whose theta varies within a block passed validation.
  • print.undirected_sbm() printed a field that doesn't exist. x$edge_distribution is NULL, so glue() returned character(0). That line and the blank line after it silently disappeared, and "Factor model parameterization" ran straight on from the block probabilities.

Fix

  • any(distinct_theta_by_block > 1).
  • Remove the edge_distribution line and keep the section break. poisson_edges and allow_self_loops are already printed further down, like the other print methods.

Tests

Added to tests/testthat/test-undirected-sbms.R. Setting m$theta <- 1:10 on an SBM now fails validation, and the print output has its section break. Fails on main (2 failures), passes here. Full suite passes. No man/ changes.

NEWS

Left out to avoid conflicting with #59. Probably not worth a bullet. If you want one, under Bug fixes:

  • validate_undirected_sbm() now actually checks that theta is constant within blocks, and print() for SBMs no longer drops a line.

🤖 Generated with Claude Code

- `any(distinct_theta_by_block) > 1` compared a logical with 1, so the
  "theta must be equal within a block" check could never fire. Use
  `any(distinct_theta_by_block > 1)`.
- print.undirected_sbm() printed `x$edge_distribution`, a field that
  doesn't exist. glue() returned character(0), so the line and the
  blank line after it silently disappeared. Remove it: Poisson edges
  and self loops are already printed below.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant