Commit 63e23b1d authored by Tiago Peixoto's avatar Tiago Peixoto

Fix bug with model selection in nested_blockmodel.py

parent 3ad8fbf8
......@@ -677,6 +677,8 @@ def replace_level(l, state, min_B=None, max_B=None, max_b=None, nsweeps=10,
nested_dl = l < len(state.levels) - 1
state.levels[l].clabel.a = cclabel.a
Sb = get_b_dl(state.levels[l],
dense=(l > 0 and state.deg_corr != "full") or dense,
multigraph=l > 0 or multigraph,
......@@ -684,6 +686,8 @@ def replace_level(l, state, min_B=None, max_B=None, max_b=None, nsweeps=10,
nested_overlap=state.overlap == "full",
dl_ent=dl_ent)
state.levels[l].clabel.a = 0
if _bm_test():
assert clabel.a.max() + 1 <= min_B
......@@ -744,12 +748,6 @@ def replace_level(l, state, min_B=None, max_B=None, max_b=None, nsweeps=10,
assert (res.clabel.a == cclabel.a).all(), (res.clabel.a, cclabel.a)
assert res._BlockState__check_clabel(), "invalid clabel after minimize!"
res.clabel.a = 0
if state.ec is not None:
for s in res.states:
s.clabel.a = 0
b = res.b
Sf = get_b_dl(res,
dense=(l > 0 and state.deg_corr != "full") or dense,
multigraph=l > 0 or multigraph,
......@@ -757,6 +755,12 @@ def replace_level(l, state, min_B=None, max_B=None, max_b=None, nsweeps=10,
nested_overlap=state.overlap == "full",
dl_ent=dl_ent)
res.clabel.a = 0
if state.ec is not None:
for s in res.states:
s.clabel.a = 0
b = res.b
kept = False
if Sf - Sb >= -1e-10:
kept = True
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment