ability to prevent force casts in numpy arguments

This commit is contained in:
Wenzel Jakob
2016-05-19 16:02:09 +02:00
parent 93a317eca1
commit b47a9de035
5 changed files with 28 additions and 13 deletions

View File

@@ -33,4 +33,9 @@ void init_ex10(py::module &m) {
// Vectorize a complex-valued function
m.def("vectorized_func3", py::vectorize(my_func3));
/// Numpy function which only accepts specific data types
m.def("selective_func", [](py::array_t<int, py::array::c_style>) { std::cout << "Int branch taken. "<< std::endl; });
m.def("selective_func", [](py::array_t<float, py::array::c_style>) { std::cout << "Float branch taken. "<< std::endl; });
m.def("selective_func", [](py::array_t<std::complex<float>, py::array::c_style>) { std::cout << "Complex float branch taken. "<< std::endl; });
}