Python新手:老C++;与Python接口的代码使用不推荐的boost/Python/numeric.hpp而不是NumPy。如何更新?

Python新手:老C++;与Python接口的代码使用不推荐的boost/Python/numeric.hpp而不是NumPy。如何更新?,python,c++,python-2.7,numpy,boost,Python,C++,Python 2.7,Numpy,Boost,我正在Mac(10.12.6)上使用Python 2.7.10。对于任何愚蠢的评论,我先道歉:我是Python新手,也不是C++的经验者。p> 我需要编译一个与Python接口的基于C++的旧代码。一些.cpp文件使用不推荐使用的“boost/python/numeric.hpp”作为包含项并用于生成数组: #include <boost/python/numeric.hpp> const py::numeric::array& X #包括 常量py::数值::数组和X

我正在Mac(10.12.6)上使用Python 2.7.10。对于任何愚蠢的评论,我先道歉:我是Python新手,也不是C++的经验者。p> 我需要编译一个与Python接口的基于C++的旧代码。一些.cpp文件使用不推荐使用的“boost/python/numeric.hpp”作为包含项并用于生成数组:

#include <boost/python/numeric.hpp>
const py::numeric::array& X
#包括
常量py::数值::数组和X
我花了几天的时间试图找出如何处理这个问题,但作为一个新手,我找不到任何有意义的文档。如果有人能为我指出正确的方向,我将不胜感激。我遇到的一件事是这篇帖子:

其中一个建议涉及使用

#include <numpy/ndarrayobject.h>
#包括
然而,我就是不知道如何使用它来翻译我的旧代码

谢谢你的帮助


根据sehe进行编辑: 代码太大,无法完整发布,但所有错误似乎都与以下方面有关:

#include <boost/python/numeric.hpp>
#包括
我非常确定我需要使用:

#include <numpy/ndarrayobject.h>
#包括
但是,我不知道如何更改引用数组的代码。 这看起来很简单,但我还没有找到任何文档。下面是不推荐使用的代码是一个问题的具体示例(请让我知道我是否可以让这更容易理解)

在main()文件“PyMain.cpp”中:

//从Boost包含
#包括
名称空间py=boost::python;
//其他包括PyCalculator代码
#XXX。。。
#XXX。。。
BOOST_PYTHON_模块(PyCalculator)
{
//将numpy设置为numeric::array引擎
py::numeric::array::set_module_和_type(“numpy”、“ndarray”);
XXX/(其他无问题代码)
}
下面是另一个文件“Auxiliary.cpp”的示例

终端中显示的错误为:

PyAux.cpp: fatal error: 
          'boost/python/numeric.hpp' file not found


#include "PyAux.hpp"
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <Python.h>
#include <numpy/ndarrayobject.h>

// Boost includes
#include <boost/python.hpp>
#include <boost/python/numeric.hpp>
#include <boost/python/slice.hpp>
#include <boost/smart_ptr.hpp>
namespace py = boost::python;

// Other includes
#include <PyAux/Math/Other/Core>

namespace PyCalculator {
... XXX
// There are functions like:
    static auto initializeWithArray(const py::numeric::array& array) -> boost::shared_ptr<VectorType>
    { //...XXX 
        const py::numeric::array& X
    }
}
PyAux.cpp:致命错误:
找不到“boost/python/numeric.hpp”文件
#包括“PyAux.hpp”
#定义NPY\u否\u已弃用\u API NPY\u 1\u 7\u API\u版本
#包括
#包括
//促进包括
#包括
#包括
#包括
#包括
名称空间py=boost::python;
//其他包括
#包括
名称空间PyCalculator{
…XXX
//有如下功能:
静态自动初始化数组(const py::numeric::array&array)->boost::shared\u ptr
{/…XXX
常量py::数值::数组和X
}
}

如果你有一个小的、独立的例子,包含一个最小的C++模块和Python用户代码,我(或其他人)可以试试我的手,谢谢,我会很感激的。我会试着准备一个(它是一个巨大的代码)。我希望可以简单的使用“包含”代替“包含”。然后在ndarrayobject中使用一些数组容器,但看起来这是不可能的很明显,这超出了你的问题范围。你的问题是关于接口代码的,这应该是可行的是的,你是对的,sehe。所有的错误都与boost/python/numeric.hpp有关。我的挑战是作为一个新手想出一个有代表性的例子。我正在研究它,但可能需要一点时间谢谢。如果你有一个小型的、独立的例子,包含一个最小的C++模块和Python用户代码,我(或其他人)可以试试我的手,谢谢。我会很感激的。我会试着准备一个(它是一个巨大的代码)。我希望可以简单的使用“包含”代替“包含”。然后在ndarrayobject中使用一些数组容器,但看起来这是不可能的很明显,这超出了你的问题范围。你的问题是关于接口代码的,这应该是可行的是的,你是对的,sehe。所有的错误都与boost/python/numeric.hpp有关。我的挑战是作为一个新手想出一个有代表性的例子。我正在研究它,但可能需要一点时间e!谢谢。
PyAux.cpp: fatal error: 
          'boost/python/numeric.hpp' file not found


#include "PyAux.hpp"
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <Python.h>
#include <numpy/ndarrayobject.h>

// Boost includes
#include <boost/python.hpp>
#include <boost/python/numeric.hpp>
#include <boost/python/slice.hpp>
#include <boost/smart_ptr.hpp>
namespace py = boost::python;

// Other includes
#include <PyAux/Math/Other/Core>

namespace PyCalculator {
... XXX
// There are functions like:
    static auto initializeWithArray(const py::numeric::array& array) -> boost::shared_ptr<VectorType>
    { //...XXX 
        const py::numeric::array& X
    }
}