Xtensor的PyBind11详细信息。
pyxtensor的Python项目详细描述
#pyxtensor
<;!--markdownto-->;
-[简介](简介)
-[用法](用法)
-[使用“setup.py”编译项目](使用setuppy编译项目)
-[开发](开发)
<;!--/markdowntoc-->;
\introduction
这个库提供了[pybind11]的详细信息(https://github.com/pybind/pybind11),这样当包含一个函数时,会自动提供到numpy数组的接口,该函数接受任何[xtensor]类(https://github.com/quantstack/xtensor)作为(返回)参数。
>;行为与[xtensor python]有明显不同(https://github.com/quantstack/xtensor python)。后者将numpy数组“映射”到所谓的“xt::pyarray”,从而提供对它的直接内存访问。相反,[pyxtensor](https://github.com/tdegeus/pyxtensor)将numpy对象复制到“xt::array”或“xt::tensor”,反之亦然。这导致了一个更简单的用法,其中C++库可以没有任何包装函数而暴露,但是,使用拷贝的缺点(花费时间和不允许的修改)。pyxtensor/pyxtensor.hpp>;
xt::xarray<;double>;times2(const xt::xarray<;double>&;a)
{
返回2。*a;
}
namespace py=pybind11;
{
m.def(“timestwo”&;timestwo);
}
`````
有关编译策略,请参见[pybind11_examples](https://github.com/tdegeus/pybind11_examples)。
头部和python模块都可以使用setuptools import setup中的pyxtensor安装pyxtensor。扩展名
import sys,re
import setuptools
import pybind11
import pyxtensor
ext\u modules=[
扩展名(
'modulename',
['path/to/pybind11/interface.cpp'],
include\dirs=[
pybind11.get-include(false),
pybind11.get-include(true),
pyxtensor.get-include(false),
pyxtensor.get\u include(true),
pyxtensor.find\xtensor(),
pyxtensor.find\xtl(),
pyxtensor.find\eigen(),
],
language='c++'
],
]
安装(
名称='modulename',
描述='short description',
长描述='long description',
版本='v0.1.2',
许可证='mit',
作者='tom de geus',
作者电子邮件='…',
URL='https://github.com/…',
外部模块=外部模块,
安装需要=['pybind11>;=2.2.0','pyxtensor>;=0.0.1'],
cmdclass={build-ext':pyxtensor.buildext},
zip-safe=false,
)
``````
更新“include/pyxtensor/pyxtensor.hpp”中的版本号,如下所示。
2.将更改上载到github并在那里创建一个新版本(使用正确的版本号)。
3。将包上载到pypi:
`` bash
python setup.py bdist_wheel--universal
捆绳上载距离/*
```
<;!--markdownto-->;
-[简介](简介)
-[用法](用法)
-[使用“setup.py”编译项目](使用setuppy编译项目)
-[开发](开发)
<;!--/markdowntoc-->;
\introduction
这个库提供了[pybind11]的详细信息(https://github.com/pybind/pybind11),这样当包含一个函数时,会自动提供到numpy数组的接口,该函数接受任何[xtensor]类(https://github.com/quantstack/xtensor)作为(返回)参数。
>;行为与[xtensor python]有明显不同(https://github.com/quantstack/xtensor python)。后者将numpy数组“映射”到所谓的“xt::pyarray”,从而提供对它的直接内存访问。相反,[pyxtensor](https://github.com/tdegeus/pyxtensor)将numpy对象复制到“xt::array”或“xt::tensor”,反之亦然。这导致了一个更简单的用法,其中C++库可以没有任何包装函数而暴露,但是,使用拷贝的缺点(花费时间和不允许的修改)。pyxtensor/pyxtensor.hpp>;
xt::xarray<;double>;times2(const xt::xarray<;double>&;a)
{
返回2。*a;
}
namespace py=pybind11;
m.def(“timestwo”&;timestwo);
}
`````
有关编译策略,请参见[pybind11_examples](https://github.com/tdegeus/pybind11_examples)。
头部和python模块都可以使用setuptools import setup中的pyxtensor安装pyxtensor。扩展名
import sys,re
import setuptools
import pybind11
import pyxtensor
ext\u modules=[
扩展名(
'modulename',
['path/to/pybind11/interface.cpp'],
include\dirs=[
pybind11.get-include(false),
pybind11.get-include(true),
pyxtensor.get-include(false),
pyxtensor.get\u include(true),
pyxtensor.find\xtensor(),
pyxtensor.find\xtl(),
pyxtensor.find\eigen(),
],
language='c++'
],
]
安装(
名称='modulename',
描述='short description',
长描述='long description',
版本='v0.1.2',
许可证='mit',
作者='tom de geus',
作者电子邮件='…',
URL='https://github.com/…',
外部模块=外部模块,
安装需要=['pybind11>;=2.2.0','pyxtensor>;=0.0.1'],
cmdclass={build-ext':pyxtensor.buildext},
zip-safe=false,
)
``````
更新“include/pyxtensor/pyxtensor.hpp”中的版本号,如下所示。
2.将更改上载到github并在那里创建一个新版本(使用正确的版本号)。
3。将包上载到pypi:
`` bash
python setup.py bdist_wheel--universal
捆绳上载距离/*
```