Created
June 14, 2018 14:38
-
-
Save nbecker/7c0dd75b213f06612eb610c613f9acec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "pybind11/pybind11.h" | |
#include "pybind11/operators.h" | |
#include "numpy/arrayobject.h" | |
#include "ndarray/pybind11.h" | |
#include "xtensor/xarray.hpp" | |
#include "xtensor/xtensor.hpp" | |
#include "xtensor/xcontainer.hpp" | |
#include "xtensor-python/pyarray.hpp" | |
#include "xtensor-python/pytensor.hpp" | |
namespace py = pybind11; | |
struct test1 { | |
xt::xtensor<double,1> a; | |
test1 (xt::xtensor<double,1> const& _a) : a (_a) {} | |
}; | |
PYBIND11_PLUGIN (test1) { | |
if (_import_array() < 0) { | |
PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); | |
return nullptr; | |
} | |
py::module m("test1", "pybind11 example plugin"); | |
py::class_<test1> (m, "test1", py::dynamic_attr()) | |
.def (py::init<xt::pytensor<const double,1> >()) | |
; | |
return m.ptr(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment