Hi there,
I cannot reproduce the issue on a ReprEx with in-built data, so it may not be a bug. But I can reproduce it on a bunch of data (e.g., sharetot.graphml) that used to work fine until I ran some updates on my Ubuntu 22.04.4 LTS system. I tried removing and re-installing graph-tool
, but to no avail.
As per the title, running a mcmc_equilibrate on a LayeredBlockState produces the error:
Traceback (most recent call last):
Cell In[7], line 1
mcmc_equilibrate(res_sharetot_lT_dF_oF, wait=1000, mcmc_args=dict(niter=10),
File /usr/local/lib/python3.10/dist-packages/graph_tool/inference/mcmc.py:117 in mcmc_equilibrate
S = state.entropy(**mcmc_args.get("entropy_args", {}))
File /usr/local/lib/python3.10/dist-packages/graph_tool/inference/base_states.py:49 in wrapper
S = func(self, *args, **kwargs)
File /usr/local/lib/python3.10/dist-packages/graph_tool/inference/nested_blockmodel.py:374 in entropy
S += kwargs.get("beta_dl", 1.) * self._Lrecdx_entropy()
File /usr/local/lib/python3.10/dist-packages/graph_tool/inference/nested_blockmodel.py:343 in _Lrecdx_entropy
S_D[j] -= log(B_E_D)
NameError: name 'log' is not defined
Work flow:
from graph_tool.all import *
import os
import re
import matplotlib
import numpy
import math
import pickle
sharetot = load_graph('./sharetot.graphml')
# Verify the property names
sharetot.list_properties()
recs = (sharetot.ep['Base metals'],
sharetot.ep['Bulk of trade'],
sharetot.ep['Machinery'],
sharetot.ep['Processed food'],
sharetot.ep['Stones'])
rec_types = ['real-normal', 'real-normal', 'real-normal',
'real-normal', 'real-normal']
sharetot.vp.period = sharetot.vp.period.coerce_type()
sharetot.ep.layer = sharetot.ep.layer.coerce_type()
state_sharetot_lF_dF_oF = LayeredBlockState(g = sharetot, ec = sharetot.ep.layer,
recs = recs, rec_types = rec_types,
pclabel = sharetot.vp.period.get_array(),
layers = False, deg_corr = False,
overlap = False)
res_sharetot_lT_dF_oF = minimize_nested_blockmodel_dl(sharetot,
state_args = dict(
base_type=LayeredBlockState,
state_args=dict(
ec = sharetot.ep.layer,
recs = recs, rec_types = rec_types,
pclabel = sharetot.vp.period.get_array(),
layers = True, deg_corr = False,
overlap = False
)
)
)
dS, nmoves=0, 0
for i in range(100):
ret=res_sharetot_lT_dF_oF.multiflip_mcmc_sweep(niter=10)
dS+=ret[0]
nmoves+=ret[1]
print("Change in description length:", dS)
print("Number of accepted vertex moves:", nmoves)
# Equilibrate a MCMC to improve the partition
# Efficient Monte Carlo heuristic for the inference of stochastic block models
mcmc_equilibrate(res_sharetot_lT_dF_oF, wait=1000, mcmc_args=dict(niter=10),
verbose=True)