Commit 5229271f authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix BlockState destructor

parent 39963df0
......@@ -198,14 +198,14 @@ class BlockState(object):
libcommunity.init_lgamma(int(3 * max(self.E, self.N)))
def __del__(self):
if BlockState is not None:
return
BlockState._state_ref_count -= 1
if BlockState._state_ref_count == 0:
libcommunity.clear_safelog()
libcommunity.clear_xlogx()
libcommunity.clear_lgamma()
try:
BlockState._state_ref_count -= 1
if BlockState._state_ref_count == 0:
libcommunity.clear_safelog()
libcommunity.clear_xlogx()
libcommunity.clear_lgamma()
except (ValueError, AttributeError):
pass
def __repr__(self):
return "<BlockState object with %d blocks,%s for graph %s, at 0x%x>" % \
......@@ -1469,8 +1469,6 @@ def multilevel_minimize(state, B, nsweeps=10, adaptive_sweeps=True, epsilon=0,
:doi:`10.1103/PhysRevE.89.012804`, :arxiv:`1310.4378`.
"""
nonoverlap_compare = kwargs.get("nonoverlap_compare", False)
if minimize_state is None:
minimize_state = MinimizeState()
b_cache = minimize_state.b_cache
......@@ -1483,6 +1481,11 @@ def multilevel_minimize(state, B, nsweeps=10, adaptive_sweeps=True, epsilon=0,
kwargs = copy.copy(kwargs)
kwargs.update(nkwargs)
nonoverlap_compare = kwargs.get("nonoverlap_compare", False)
if "nonoverlap_compare" in kwargs:
del kwargs["nonoverlap_compare"]
assert not nonoverlap_compare, "don't do this"
orig_state = state
if __test__:
......
......@@ -665,7 +665,7 @@ def replace_level(l, state, min_B=None, max_B=None, max_b=None, nsweeps=10,
nested_dl=nested_dl,
overlap=bstate.overlap,
nested_overlap=state.overlap == "full",
nonoverlap_compare=init_states is None,
nonoverlap_compare=False,
nonoverlap_init=False,
init_states=init_states,
verbose=verbose=="full",
......
......@@ -232,8 +232,10 @@ class OverlapBlockState(BlockState):
libcommunity.init_lgamma(int(3 * max(self.E, self.N)))
def __del__(self):
if BlockState is not None:
try:
BlockState.__del__(self)
except (TypeError, AttributeError):
pass
def __repr__(self):
return "<OverlapBlockState object with %d blocks,%s for graph %s, at 0x%x>" % \
......
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