ability to prevent force casts in numpy arguments
diff --git a/example/example10.cpp b/example/example10.cpp
index 09769fe..cbe737e 100644
--- a/example/example10.cpp
+++ b/example/example10.cpp
@@ -33,4 +33,9 @@
// 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; });
}
diff --git a/example/example10.py b/example/example10.py
index 0d49fca..b18e729 100755
--- a/example/example10.py
+++ b/example/example10.py
@@ -27,3 +27,8 @@
print(f(np.array([[1, 2, 3], [4, 5, 6]]), np.array([[2], [3]]), 2))
print(np.array([[1, 2, 3], [4, 5, 6]])* np.array([[2], [3]])* 2)
+from example import selective_func
+
+selective_func(np.array([1], dtype=np.int32))
+selective_func(np.array([1.0], dtype=np.float32))
+selective_func(np.array([1.0j], dtype=np.complex64))
diff --git a/example/example10.ref b/example/example10.ref
index 9d48d7c..4885fc1 100644
--- a/example/example10.ref
+++ b/example/example10.ref
@@ -73,3 +73,6 @@
[ 24. 30. 36.]]
[[ 4 8 12]
[24 30 36]]
+Int branch taken.
+Float branch taken.
+Complex float branch taken.