graspologic-org / graspologic

Python package for graph statistics
https://graspologic-org.github.io/graspologic/
MIT License
634 stars 134 forks source link

[BUG] SBMEstimator throws an error when "loops=False" and some block has size 1 #1055

Open bokveizen opened 5 months ago

bokveizen commented 5 months ago

Expected Behavior

Any size-1 block should just have zero probability.

Actual Behavior

In sbm_estimators.py, _calculate_block_p calls _calculate_p, which divides zero when block.size = 0. This can happen when some block has size one and loops=False is used.

Adding

if block.size == 0:
    continue

before Line 519 of graspologic/graspologic/models/sbm_estimators.py should do the trick.