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

Add eweight and vweight parameters to Nested/Covariate/Overlap/BlockState.copy()

parent d6716457
......@@ -243,7 +243,8 @@ class BlockState(object):
def copy(self, g=None, b=None, B=None, deg_corr=None, clabel=None, overlap=False):
def copy(self, g=None, eweight=None, vweight=None, b=None, B=None,
deg_corr=None, clabel=None, overlap=False):
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
......@@ -251,8 +252,8 @@ class BlockState(object):
if not overlap:
state = BlockState(self.g if g is None else g,
eweight=self.eweight,
vweight=self.vweight,
eweight=self.eweight if eweight is None else eweight,
vweight=self.vweight if vweight is None else vweight,
b=self.b.copy() if b is None else 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,
......
......@@ -468,14 +468,14 @@ class CovariateBlockState(BlockState):
self.__init__(**state)
return state
def copy(self, g=None, b=None, B=None, deg_corr=None, clabel=None,
overlap=None, layers=None, ec=None):
def copy(self, g=None, eweight=None, vweight=None, b=None, B=None,
deg_corr=None, clabel=None, overlap=None, layers=None, ec=None):
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,
ec=self.ec if ec is None else ec,
eweight=self.eweight,
vweight=self.vweight,
eweight=self.eweight if eweight is None else eweight,
vweight=self.vweight if vweight is None else vweight,
b=self.b if b is None else b,
B=(self.B if b is None else None) if B is None else B,
clabel=(self.clabel.a if self.overlap else self.clabel) if clabel is None else clabel,
......
......@@ -158,8 +158,8 @@ class NestedBlockState(object):
" degree corrected," if self.deg_corr else "",
str(self.g), len(self.levels), str([(s.N, s.B) for s in self.levels]), id(self))
def copy(self, g=None, bs=None, ec=None, layers=None, deg_corr=None,
overlap=None, clabel=None):
def copy(self, g=None, eweight=None, vweight=None, bs=None, ec=None,
layers=None, deg_corr=None, overlap=None, clabel=None):
r"""Copies the block state. The parameters override the state properties, and
have the same meaning as in the constructor.."""
......@@ -176,8 +176,10 @@ class NestedBlockState(object):
deg_corr = self.deg_corr
if layers is None:
layers = self.layers
return NestedBlockState(self.g if g is None else g, self.eweight,
self.vweight, self.ec if ec is None else ec, bs,
return NestedBlockState(self.g if g is None else g,
self.eweight if eweight is None else eweight,
self.vweight if vweight is None else vweight,
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)
......
......@@ -254,15 +254,16 @@ class OverlapBlockState(BlockState):
self.partition_stats = libcommunity.overlap_partition_stats()
def copy(self, g=None, b=None, B=None, deg_corr=None, clabel=None, overlap=True):
def copy(self, g=None, eweight=None, vweight=None, b=None, B=None,
deg_corr=None, clabel=None, overlap=True):
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."""
if overlap:
state = OverlapBlockState(self.g if g is None else g,
eweight=self.eweight,
vweight=self.vweight,
eweight=self.eweight if eweight is None else eweight,
vweight=self.vweight if vweight is None else vweight,
b=self.b if b is None else b,
B=(self.B if b is None else None) if B is None else B,
clabel=self.clabel.a if clabel is None else clabel,
......
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