mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-16 21:57:55 +00:00
add tests
This commit is contained in:
parent
4d785be984
commit
cba2b32ead
@ -131,6 +131,15 @@ arr_t &mutate_at_t(arr_t &a, Ix... idx) {
|
|||||||
a.mutable_at(idx...)++;
|
a.mutable_at(idx...)++;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
template <typename... Ix>
|
||||||
|
arr_t &call_operator_subscript_t(arr_t &a, Ix... idx) {
|
||||||
|
a(idx...)++;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
template <typename... Ix>
|
||||||
|
py::ssize_t const_call_operator_subscript_t(const arr_t &a, Ix... idx) {
|
||||||
|
return a(idx...);
|
||||||
|
}
|
||||||
|
|
||||||
#define def_index_fn(name, type) \
|
#define def_index_fn(name, type) \
|
||||||
sm.def(#name, [](type a) { return name(a); }); \
|
sm.def(#name, [](type a) { return name(a); }); \
|
||||||
@ -210,6 +219,8 @@ TEST_SUBMODULE(numpy_array, sm) {
|
|||||||
def_index_fn(mutate_data_t, arr_t &);
|
def_index_fn(mutate_data_t, arr_t &);
|
||||||
def_index_fn(at_t, const arr_t &);
|
def_index_fn(at_t, const arr_t &);
|
||||||
def_index_fn(mutate_at_t, arr_t &);
|
def_index_fn(mutate_at_t, arr_t &);
|
||||||
|
def_index_fn(call_operator_subscript_t, arr_t &);
|
||||||
|
def_index_fn(const_call_operator_subscript_t, const arr_t &);
|
||||||
|
|
||||||
// test_make_c_f_array
|
// test_make_c_f_array
|
||||||
sm.def("make_f_array", [] { return py::array_t<float>({2, 2}, {4, 8}); });
|
sm.def("make_f_array", [] { return py::array_t<float>({2, 2}, {4, 8}); });
|
||||||
|
Loading…
Reference in New Issue
Block a user