Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmp_index is shorter than to_index sometimes, especially in small and degenerate blockmodels #13

Closed
alexpghayes opened this issue Feb 19, 2021 · 2 comments

Comments

@alexpghayes
Copy link
Collaborator

alexpghayes commented Feb 19, 2021

Playing around with different seeds in the degenerate SBM test reveals a variety of new and exciting issues. TL; DR: if you need to sample small graphs (or potentially SBMs with k ~ n), you may run into issues.

For some reason this errors for me when run by testthat but not interactively.

library(fastRG)

set.seed(5)

n <- 10
k <- 10
pi <- rep(1, k) / k

B <- diag(rep(0.5, k))

sbm <- sbm(n = n, pi = pi, B = B)

sample_sparse(sbm)

If this becomes a blocker for anyone, please let me know.

@alexpghayes
Copy link
Collaborator Author

Reprex

library(fastRG)
#> Loading required package: Matrix

set.seed(7)

n <- 10
k <- 10
pi <- rep(1, k) / k

B <- diag(rep(0.5, k))

sbm <- sbm(n = n, pi = pi, B = B)

sample_sparse(sbm)
#> Error in to[to_index] <- to_tmp[tmp_index]: replacement has length zero

Created on 2022-06-29 by the reprex package (v2.0.1)

Can also get a version of this that is only a warning:

> sample_sparse(sbm)
10 x 10 sparse Matrix of class "dsCMatrix"

[1,] . . . . . . . . . .
[2,] . . . . . . . . . .
[3,] . . . . . . . . . .
[4,] . . . . 3 1 . . . .
[5,] . . . 3 1 . . . . .
[6,] . . . 1 . . . . . .
[7,] . . . . . . . . . .
[8,] . . . . . . . . . .
[9,] . . . . . . . . . .
[10,] . . . . . . . . . .
Warning message:
  In to[to_index] <- to_tmp[tmp_index] :
  number of items to replace is not a multiple of replacement length

@alexpghayes alexpghayes changed the title Issues remain with degenerate blockmodels tmp_index is shorter than to_index sometimes, especially in small and degenerate blockmodels Jun 29, 2022
@alexpghayes
Copy link
Collaborator Author

@karlrohe I'm pretty sure this I found this fix for this, but if you have a moment and you can take a look at e9ea60e, I would appreciate it! Only a one line change of code for what I think is the fix.

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

No branches or pull requests

1 participant