Skip to content

Reject redundant or contradictory arguments in model constructors - #68

Draft
alexpghayes wants to merge 1 commit into
mainfrom
fix/contradictory-args
Draft

alexpghayes wants to merge 1 commit into
mainfrom
fix/contradictory-args

Conversation

@alexpghayes

Copy link
Copy Markdown
Collaborator

Bugs

Call On main
directed_dcsbm(n = 10, B = matrix(.1, 2, 3), k_out = 5, k_in = 3) k_out silently ignored
mmsbm(theta = rep(1, 10), k = 3, B = B) "subscript out of bounds" / "missing value where TRUE/FALSE needed"
mmsbm(n = 100, theta = rep(1, 10), B = B) n silently ignored
mmsbm(theta = rep(1, 10), B = matrix(.5)) (k = 1) "Dirichlet parameter vector too short" from igraph
mmsbm() / overlapping_sbm() with force_pure = TRUE and n < k cryptic error from sample()
chung_lu(n = 100, theta = rep(1, 10)) n silently ignored

Fix

  • mmsbm() and chung_lu(): "Must specify only one of n and theta, not both." and "Must specify only one of B and k, not both.", worded as in dcsbm().
  • mmsbm() with k < 2: "mmsbm() needs at least two blocks. For a single block, use chung_lu() or dcsbm()."
  • mmsbm() / overlapping_sbm(): "force_pure = TRUE needs at least as many nodes as blocks (n >= k)." The overlapping_sbm() docs already said this.
  • directed_dcsbm() differs from the handoff's suggestion. Its docs explicitly allow giving k_out, k_in and B together ("You may specify all three at once"). So instead of an "only one of" error, it now errors only when they contradict B: "k_out must equal nrow(B) when both are given." (likewise for k_in / ncol(B)). The docs now say that. Happy to switch to a strict "only one of" error like dcsbm(), which would be a breaking change.

Tests

New tests/testthat/test-contradictory-args.R. Fails on main (3 failures, 2 errors), passes here. Full suite passes. Docs regenerated with roxygen2 7.3.2.

NEWS

Left out to avoid conflicting with #59. Suggested bullet under Bug fixes:

  • mmsbm() and chung_lu() now error when both n and theta are given (previously n was silently ignored), and mmsbm() errors when both k and B are given, like dcsbm(). directed_dcsbm() errors when k_out or k_in disagree with the dimensions of B. mmsbm() gives clear errors for k = 1, and mmsbm() and overlapping_sbm() for force_pure = TRUE with fewer nodes than blocks.

🤖 Generated with Claude Code

- directed_dcsbm(): `k_out` / `k_in` that disagree with `dim(B)` are an
  error instead of being silently ignored. Agreeing values are still
  allowed, as documented.
- mmsbm(): specifying both `k` and `B`, or both `n` and `theta`, is an
  error, matching dcsbm(). `k = 1` errors clearly instead of failing
  inside igraph.
- mmsbm() and overlapping_sbm(): `force_pure = TRUE` with `n < k`
  errors clearly.
- chung_lu(): specifying both `n` and `theta` is an error.

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