Commit 1e5a0f49 authored by Tiago Peixoto's avatar Tiago Peixoto

Fix possible infinite loop in Overlap/Covariate/BlockState.copy()

parent b65db1f2
......@@ -264,12 +264,11 @@ class BlockState(object):
max_BE=self.max_BE, **kwargs)
if not state.__check_clabel():
if _bm_test() or not kwargs.get("fix_clabel", True) :
raise RuntimeError("Inconsistent clabel after copy!")
b = state.b.a + state.clabel.a * state.B
continuous_map(b)
state = state.copy(b=b)
if _bm_test():
assert state.__check_clabel()
state = state.copy(b=b, fix_clabel=False)
return state
......
......@@ -488,7 +488,8 @@ class CovariateBlockState(BlockState):
return self.copy(g=g, ec=ec, b=b.fa, clabel=clabel.fa)
def copy(self, g=None, eweight=None, vweight=None, b=None, B=None,
deg_corr=None, clabel=None, overlap=None, layers=None, ec=None):
deg_corr=None, clabel=None, overlap=None, layers=None, ec=None,
**kwargs):
r"""Copies the block state. The parameters override the state properties, and
have the same meaning as in the constructor."""
state = CovariateBlockState(self.g if g is None else g,
......@@ -508,12 +509,11 @@ class CovariateBlockState(BlockState):
ec_done=ec is None)
if not state._BlockState__check_clabel():
if _bm_test() or not kwargs.get("fix_clabel", True) :
raise RuntimeError("Inconsistent clabel after copy!")
b = state.b.a + state.clabel.a * state.B
continuous_map(b)
state = state.copy(b=b)
if _bm_test():
assert state._BlockState__check_clabel()
state = state.copy(b=b, fix_clabel=False)
return state
......
......@@ -253,7 +253,7 @@ class OverlapBlockState(BlockState):
return self.copy(g=g, b=b.fa, clabel=clabel.fa)
def copy(self, g=None, eweight=None, vweight=None, b=None, B=None,
deg_corr=None, clabel=None, overlap=True):
deg_corr=None, clabel=None, overlap=True, **kwargs):
r"""Copies the block state. The parameters override the state properties, and
have the same meaning as in the constructor. If ``overlap=False`` an
instance of :class:`~graph_tool.community.BlockState` is returned. This
......@@ -281,12 +281,11 @@ class OverlapBlockState(BlockState):
max_BE=self.max_BE)
if not state._BlockState__check_clabel():
if _bm_test() or not kwargs.get("fix_clabel", True) :
raise RuntimeError("Inconsistent clabel after copy!")
b = state.b.a + state.clabel.a * state.B
continuous_map(b)
state = state.copy(b=b)
if _bm_test():
assert state._BlockState__check_clabel()
state = state.copy(b=b, fix_clabel=False)
return state
......
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