diff options
author | Miodrag Milanović <mmicko@gmail.com> | 2021-01-02 11:16:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-02 11:16:49 +0100 |
commit | 9b9628047c01a970cfe20f83f2b7129ed109440d (patch) | |
tree | 1db418e9a889dc6fbe6199c5259aac9bd8cbb32f /3rdparty/pybind11/tests/test_numpy_vectorize.cpp | |
parent | c6cdf30501dcb2da01361229dd66a05dad73a132 (diff) | |
parent | 61b07bc9a664d6a88b85aae99f9756d7569688a9 (diff) | |
download | nextpnr-9b9628047c01a970cfe20f83f2b7129ed109440d.tar.gz nextpnr-9b9628047c01a970cfe20f83f2b7129ed109440d.tar.bz2 nextpnr-9b9628047c01a970cfe20f83f2b7129ed109440d.zip |
Merge pull request #549 from YosysHQ/update
Update pybind11 version and fix for future python versions
Diffstat (limited to '3rdparty/pybind11/tests/test_numpy_vectorize.cpp')
-rw-r--r-- | 3rdparty/pybind11/tests/test_numpy_vectorize.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/3rdparty/pybind11/tests/test_numpy_vectorize.cpp b/3rdparty/pybind11/tests/test_numpy_vectorize.cpp index a875a74b..274b7558 100644 --- a/3rdparty/pybind11/tests/test_numpy_vectorize.cpp +++ b/3rdparty/pybind11/tests/test_numpy_vectorize.cpp @@ -17,7 +17,7 @@ double my_func(int x, float y, double z) { } TEST_SUBMODULE(numpy_vectorize, m) { - try { py::module::import("numpy"); } + try { py::module_::import("numpy"); } catch (...) { return; } // test_vectorize, test_docs, test_array_collapse @@ -37,7 +37,7 @@ TEST_SUBMODULE(numpy_vectorize, m) { )); // test_type_selection - // Numpy function which only accepts specific data types + // NumPy function which only accepts specific data types m.def("selective_func", [](py::array_t<int, py::array::c_style>) { return "Int branch taken."; }); m.def("selective_func", [](py::array_t<float, py::array::c_style>) { return "Float branch taken."; }); m.def("selective_func", [](py::array_t<std::complex<float>, py::array::c_style>) { return "Complex float branch taken."; }); @@ -50,7 +50,9 @@ TEST_SUBMODULE(numpy_vectorize, m) { NonPODClass(int v) : value{v} {} int value; }; - py::class_<NonPODClass>(m, "NonPODClass").def(py::init<int>()); + py::class_<NonPODClass>(m, "NonPODClass") + .def(py::init<int>()) + .def_readwrite("value", &NonPODClass::value); m.def("vec_passthrough", py::vectorize( [](double *a, double b, py::array_t<double> c, const int &d, int &e, NonPODClass f, const double g) { return *a + b + c.at(0) + d + e + f.value + g; @@ -81,9 +83,11 @@ TEST_SUBMODULE(numpy_vectorize, m) { py::array_t<float, py::array::forcecast> arg2, py::array_t<double, py::array::forcecast> arg3 ) { - ssize_t ndim; - std::vector<ssize_t> shape; + py::ssize_t ndim; + std::vector<py::ssize_t> shape; std::array<py::buffer_info, 3> buffers {{ arg1.request(), arg2.request(), arg3.request() }}; return py::detail::broadcast(buffers, ndim, shape); }); + + m.def("add_to", py::vectorize([](NonPODClass& x, int a) { x.value += a; })); } |