Python参数类型与C ++签名不匹配

时间:2017-01-26 12:01:52

标签: python c++ boost ubuntu-16.04 graph-tool

我一直在使用图形工具中的推理模块,并尝试从cookbook部分复制一段代码。运行gt.mcmc_equilibrate(state, wait=1000, mcmc_args=dict(niter=10))时,我收到错误消息。

它似乎围绕着与C ++签名不匹配的Python参数类型。在对不同的模块使用不同的编译器(?)时,似乎已经进行了一些搜索。在这种情况下,我正在运行从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) 

1 个答案:

答案 0 :(得分:0)

代码无法正常工作,因为在通过

执行mcmc平衡之前必须启用采样
Dim ws As Worksheet, ws2 As Worksheet

For Each ws In Worksheets
    If ws.Name Like "*!*" Then
        ws.Copy
        Set ws2 = Workbooks(Workbooks.Count).Sheets(1) ' newest workbook
        ws2.Name = LCase(Replace(Replace(ws.Name, "!", ""), "+", ""))
        ws2.UsedRange.Value = ws2.UsedRange.Value
        ws2.Parent.SaveAs ws.Parent.Path & "\" & sName & ".xlsx", CreateBackup:=False ' add checks if the file already exist and if path contains illegal characters that are not allowed
        ws2.Parent.Close False
    End If
Next

正如http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/self-state-couple-state-state-state-entropy-args-Python-argument-types-did-not-match-C-signature-td4026975.html#a4026979

所指出的那样