Skip to content

Instantly share code, notes, and snippets.

@nbecker
Created June 14, 2018 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nbecker/7c0dd75b213f06612eb610c613f9acec to your computer and use it in GitHub Desktop.
Save nbecker/7c0dd75b213f06612eb610c613f9acec to your computer and use it in GitHub Desktop.
#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