Commit f05c11df authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

(Nested)BlockState: fix preservation of "ignored_degrees" when copying and pickling

parent f2c64271
......@@ -244,7 +244,7 @@ class BlockState(object):
def copy(self, g=None, eweight=None, vweight=None, b=None, B=None,
deg_corr=None, clabel=None, overlap=False):
deg_corr=None, clabel=None, overlap=False, **kwargs):
r"""Copies the block state. The parameters override the state properties, and
have the same meaning as in the constructor. If ``overlap=True`` an
instance of :class:`~graph_tool.community.OverlapBlockState` is
......@@ -259,14 +259,15 @@ class BlockState(object):
clabel=self.clabel if clabel is None else clabel,
deg_corr=self.deg_corr if deg_corr is None else deg_corr,
max_BE=self.max_BE,
ignore_degrees=self.ignore_degrees)
ignore_degrees=kwargs.pop("ignore_degrees", self.ignore_degrees),
**kwargs)
else:
state = OverlapBlockState(self.g if g is None else g,
b=b if b is not None else self.b,
B=(self.B if b is None else None) if B is None else B,
clabel=self.clabel if clabel is None else clabel,
deg_corr=self.deg_corr if deg_corr is None else deg_corr,
max_BE=self.max_BE)
max_BE=self.max_BE, **kwargs)
if not state.__check_clabel():
b = state.b.a + state.clabel.a * state.B
......
......@@ -159,7 +159,7 @@ class NestedBlockState(object):
str(self.g), len(self.levels), str([(s.N, s.B) for s in self.levels]), id(self))
def copy(self, g=None, eweight=None, vweight=None, bs=None, ec=None,
layers=None, deg_corr=None, overlap=None, clabel=None):
layers=None, deg_corr=None, overlap=None, clabel=None, **kwargs):
r"""Copies the block state. The parameters override the state properties, and
have the same meaning as in the constructor.."""
......@@ -182,7 +182,9 @@ class NestedBlockState(object):
self.ec if ec is None else ec, bs,
layers=layers, deg_corr=deg_corr,
overlap=overlap, clabel=clabel,
max_BE=self.levels[0].max_BE)
max_BE=self.levels[0].max_BE,
ignore_degrees=kwargs.pop("ignore_degrees", self.ignore_degrees),
**kwargs)
def __getstate__(self):
state = dict(g=self.g,
......@@ -193,7 +195,8 @@ class NestedBlockState(object):
bs=[array(s.b.a) for s in self.levels],
clabel=self.clabel,
deg_corr=self.deg_corr,
max_BE=self.levels[0].max_BE)
max_BE=self.levels[0].max_BE,
ignore_degrees=self.ignore_degrees)
return state
def __setstate__(self, state):
......
Supports Markdown
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