add tests

This commit is contained in:
Francesco Rizzi 2023-06-28 15:25:55 +02:00
parent 4d785be984
commit cba2b32ead

View File

@ -131,6 +131,15 @@ arr_t &mutate_at_t(arr_t &a, Ix... idx) {
a.mutable_at(idx...)++;
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) \
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(at_t, const 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
sm.def("make_f_array", [] { return py::array_t<float>({2, 2}, {4, 8}); });