9#include <c2py/converters/numpy_proxy.hpp>
10#include "./make_py_capsule.hpp"
12namespace nda::python {
20 template <MemoryArray AUR>
21 c2py::numpy_proxy make_numpy_proxy_from_array_or_view(AUR &&a)
25 using A = std::decay_t<AUR>;
26 using value_type =
typename A::value_type;
28 static_assert(not std::is_reference_v<value_type>,
"Logical Error");
32 if constexpr (c2py::has_npy_type<T>) {
33 std::vector<long> extents(A::rank), strides(A::rank);
35 for (
int i = 0; i < A::rank; ++i) {
36 extents[i] = a.indexmap().lengths()[i];
37 strides[i] = a.indexmap().strides()[i] *
sizeof(T);
43 std::is_const_v<value_type>,
46 make_pycapsule(a.storage())};
58 return c2py::py_converter<T>::c2py(std::move(x));
60 return c2py::py_converter<T>::c2py(x);
62 return make_numpy_proxy_from_array_or_view(std::move(aobj));
mapped< F > map(F f)
Create a lazy function call expression on arrays/views.
basic_array< ValueType, Rank, Layout, 'A', ContainerPolicy > array
Alias template of an nda::basic_array with an 'A' algebra.
constexpr bool is_regular_v
Constexpr variable that is true if type A is a regular array, i.e. an nda::basic_array.
std::decay_t< decltype(get_first_element(std::declval< A const >()))> get_value_t
Get the value type of an array/view or a scalar type.
constexpr bool is_regular_or_view_v
Constexpr variable that is true if type A is either a regular array or a view.
Includes all relevant headers for the core nda library.