9#include <c2py/py_converter.hpp>
10#include <c2py/converters/numpy_proxy.hpp>
11#include "./make_py_capsule.hpp"
13namespace nda::python {
21 template <MemoryArray AUR>
22 c2py::numpy_proxy make_numpy_proxy_from_array_or_view(AUR &&a)
26 using A = std::decay_t<AUR>;
27 using value_type =
typename A::value_type;
29 static_assert(not std::is_reference_v<value_type>,
"Logical Error");
33 if constexpr (c2py::has_npy_type<T>) {
34 std::vector<long> extents(A::rank), strides(A::rank);
36 for (
int i = 0; i < A::rank; ++i) {
37 extents[i] = a.indexmap().lengths()[i];
38 strides[i] = a.indexmap().strides()[i] *
sizeof(T);
44 std::is_const_v<value_type>,
47 make_pycapsule(a.storage())};
59 return c2py::py_converter<T>::c2py(std::move(x));
61 return c2py::py_converter<T>::c2py(x);
63 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.