Я немного поигрался с модулем логического вывода из Graph-Tool и попытался скопировать часть кода из раздела кулинарной книги. При беге gt.mcmc_equilibrate(state, wait=1000, mcmc_args=dict(niter=10))
Однако я получаю сообщение об ошибке.
Кажется, он вращается вокруг типов аргументов Python, не соответствующих сигнатурам C ++. После некоторого поиска это может возникнуть при использовании разных компиляторов для разных модулей (?). Однако в этом случае я запускаю пакет, загруженный с apt-get
(2.19 (commit da041f33, Sat Nov 12 17:27:48 2016 +0100)), поэтому я был удивлен, увидев это. Та же самая ошибка также появляется, если запустить ее на скомпилированной версии исходного кода (2.20dev (commit 01432d60, Sun Jan 15 19:54:52 2017 +0000)).
Кто-нибудь знает, что здесь происходит / как я мог это исправить?
Это соответствующий фрагмент кода:
import graph_tool.all as gt
import timeit, os
import cPickle as pickle
import numpy as np
g = gt.load_graph('graph_no_multi_reac_type.gt')
gt.remove_parallel_edges(g)
state = gt.minimize_nested_blockmodel_dl(g, deg_corr=True)
# We will first equilibrate the Markov chain
gt.mcmc_equilibrate(state, wait=1000, mcmc_args=dict(niter=10))
И это сообщение об ошибке, которое я получаю:
Traceback (most recent call last):
File "num_groups_marg_prob.py", line 26, in <module>
gt.mcmc_equilibrate(state, wait=1000, mcmc_args=dict(niter=10))
File "/usr/lib/python2.7/dist-packages/graph_tool/inference/mcmc.py", line 127, in mcmc_equilibrate
delta, nmoves = state.mcmc_sweep(**mcmc_args)
File "/usr/lib/python2.7/dist-packages/graph_tool/inference/nested_blockmodel.py", line 576, in mcmc_sweep
return self._h_sweep(lambda s, **a: s.mcmc_sweep(**a), c=c, **kwargs)
File "/usr/lib/python2.7/dist-packages/graph_tool/inference/nested_blockmodel.py", line 499, in _h_sweep
get_entropy_args(eargs))
File "/usr/lib/python2.7/dist-packages/graph_tool/inference/blockmodel.py", line 616, in _couple_state
self._state.couple_state(state._state, entropy_args)
Boost.Python.ArgumentError: Python argument types in
graph_tool::BlockState<boost::adj_list<unsigned long>, graph_tool::simple_degs_t, std::integral_constant<bool, false>, std::integral_constant<bool, false>, boost::any, boost::any, boost::any, boost::unchecked_vector_property_map<int, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, std::vector<unsigned long, std::allocator<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, std::vector<unsigned long, std::allocator<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, bool, int, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::typed_identity_property_map<unsigned long> >, double, double, double, double, double, double, boost::unchecked_vector_property_map<unsigned char, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<unsigned char, boost::typed_identity_property_map<unsigned long> >, bool>.couple_state(graph_tool::BlockState<boost::adj_list<unsigned long>, graph_tool::simple_degs_t, std::integral_constant<bool, false>, std::integral_constant<bool, false>, boost::any, boost::any, boost::any, boost::unchecked_vector_property_map<int, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, std::vector<unsigned long, std::allocator<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, std::vector<unsigned long, std::allocator<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, bool, int, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::typed_identity_property_map<unsigned long> >, double, double, double, double, double, double, boost::unchecked_vector_property_map<unsigned char, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<unsigned char, boost::typed_identity_property_map<unsigned long> >, bool>, graph_tool::BlockState<boost::adj_list<unsigned long>, graph_tool::simple_degs_t, std::integral_constant<bool, true>, std::integral_constant<bool, false>, boost::any, boost::any, boost::any, boost::unchecked_vector_property_map<int, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, std::vector<unsigned long, std::allocator<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, std::vector<unsigned long, std::allocator<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, bool, int, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::typed_identity_property_map<unsigned long> >, double, double, double, double, double, double, boost::unchecked_vector_property_map<unsigned char, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<unsigned char, boost::typed_identity_property_map<unsigned long> >, bool>, entropy_args)
did not match C++ signature:
couple_state(graph_tool::BlockState<boost::adj_list<unsigned long>, graph_tool::simple_degs_t, std::integral_constant<bool, false>, std::integral_constant<bool, false>, boost::any, boost::any, boost::any, boost::unchecked_vector_property_map<int, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, std::vector<unsigned long, std::allocator<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, std::vector<unsigned long, std::allocator<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, bool, int, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::typed_identity_property_map<unsigned long> >, double, double, double, double, double, double, boost::unchecked_vector_property_map<unsigned char, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<unsigned char, boost::typed_identity_property_map<unsigned long> >, bool> {lvalue}, graph_tool::BlockState<boost::adj_list<unsigned long>, graph_tool::simple_degs_t, std::integral_constant<bool, false>, std::integral_constant<bool, false>, boost::any, boost::any, boost::any, boost::unchecked_vector_property_map<int, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, std::vector<unsigned long, std::allocator<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, std::vector<unsigned long, std::allocator<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> >, bool, int, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::adj_edge_index_property_map<unsigned long> >, boost::unchecked_vector_property_map<double, boost::typed_identity_property_map<unsigned long> >, double, double, double, double, double, double, boost::unchecked_vector_property_map<unsigned char, boost::typed_identity_property_map<unsigned long> >, boost::unchecked_vector_property_map<unsigned char, boost::typed_identity_property_map<unsigned long> >, bool> {lvalue}, graph_tool::entropy_args_t)
Код не работал, потому что выборка должна быть включена перед выполнением уравновешивания MCMC через
state = state.copy(sampling=True)
Других решений пока нет …