Admin message

Please use the issue tracker only to report bugs (i.e. errors in the library that need to be fixed) or feature requests.

Please check if the current git version also has the same problem. An easy way to do this is to use google colab!

For questions about how to compile, install or use the library, please use instead the web forum at https://forum.skewed.de/c/graph-tool.


(If unsure, use the forum first.)


IMPORTANT: When opening new issues, please fill out the required information listed in the issue template!

Entropy discrepancy during MCMC after copying state with new state_args (pclabel change)

I want to copy a state, but change the state_args (in my case changing the PropertyMap which specifies the pclabel).

After copying, the MCMC sometimes raises an Entropy error (code must be run a few times to observe the issue).

Minimal example (files here):

import graph_tool.all as gt
import pickle
from graph_tool import inference
inference.set_test(True)

# Loaded state has strict pclabel - Each question in its own group
with open('example_state.pickle', 'rb') as handle:
    state = pickle.load(handle)

# NEW STATE ARGS. Allow question groups to be merged
new_state_args = state.state_args.copy()
new_state_args['clabel'] = state.g.vp['kind'].copy()
new_state_args['pclabel'] = state.g.vp['kind'].copy()

# Copying state with new state_args causes entropy discrepancy
s = state.copy(state_args=new_state_args)
for i in range(10):
    ret = s.multiflip_mcmc_sweep(beta=1, niter=10)

Note that I get two different, but related error messages across different runs.

Error message 1:

Traceback (most recent call last):
  File "/Users/falkenbergm/Documents/Projects/WVS_Analysis/other/minimal_example_folder/minimal_example_14/minimal_example_14.py", line 24, in <module>
    ret = s.multiflip_mcmc_sweep(beta=1, niter=10)
  File "/opt/anaconda3/envs/gt/lib/python3.13/site-packages/graph_tool/inference/base_states.py", line 85, in wrapper
    Sf = self.entropy(**entropy_args)
  File "/opt/anaconda3/envs/gt/lib/python3.13/site-packages/graph_tool/inference/base_states.py", line 58, in wrapper
    assert math.isclose(S, Salt, abs_tol=1e-8), \
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: entropy discrepancy after copying (172591 172592 -1.38629)

Error message 2:

Traceback (most recent call last):
  File "/Users/falkenbergm/Documents/Projects/WVS_Analysis/other/minimal_example_folder/minimal_example_14/minimal_example_14.py", line 19, in <module>
    ret = s.multiflip_mcmc_sweep(beta=1, niter=10)
  File "/opt/anaconda3/envs/gt/lib/python3.13/site-packages/graph_tool/inference/base_states.py", line 86, in wrapper
    assert math.isclose(dS, (Sf - Si), abs_tol=1e-8), \
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: inconsistent entropy delta -2003.88 (-1976.17): {}
  • Are you running the latest graph-tool version?: v2.98
  • Did you compile graph-tool manually?: No (conda version)
  • Your operating system: MacOS Tahoe 26.0.1
  • The Python version you are using: 3.13
Assignee Loading
Time tracking Loading