issue with gt.multicanonical_equilibrate()
Hi, running graph-tool on ubuntu 20, with graph-tool 2.37 installed from the package manager, and Python 3.8.5.
I report an issue with gt.multicanonical_equilibrate() when supplying a callback argument:
import graph_tool.all as gt
g = gt.collection.data["celegansneural"]
h = np.zeros(g.num_vertices() + 1)
def collect_partition(s,m_state):
B = s.get_nonempty_B()
h[B] += 1
state0 = gt.minimize_blockmodel_dl(g)
Smin,Smax=0.9*S0,1.1*S0
ms= gt.MulticanonicalState(state0,Smin,Smax, nbins=100)
gt.multicanonical_equilibrate(ms,callback=collect_partition)
raises the following error:
NameError Traceback (most recent call last)
<ipython-input-17-3191cac0ecbc> in <module>
----> 1 gt.multicanonical_equilibrate(ms,callback=collect_partition)
/usr/lib/python3/dist-packages/graph_tool/inference/mcmc.py in multicanonical_equilibrate(m_state, f_range, r, flatness, allow_gaps, callback, multicanonical_args, verbose)
570
571 if callback is not None:
--> 572 callback(state, m_state)
573
574 if check_verbose(verbose):
NameError: name 'state' is not defined
This maybe can be fixed as follows, in multicanonical_equilibrate():
if callback is not None:
callback(state, m_state)
#SHOULD BE: callback(m_state._state, m_state)
best!