16 #include <type_traits>
26 template <
class T,
class Allocator = std::allocator<T> >
31 bool const read_only =
false;
32 d[
"data"] = py::make_tuple(std::intptr_t(vector.
dataPtr()), read_only);
33 d[
"shape"] = py::make_tuple(vector.
size());
34 d[
"strides"] = py::none();
35 d[
"typestr"] = py::format_descriptor<T>::format();
50 template <
class T,
class Allocator = std::allocator<T> >
53 using namespace amrex;
56 auto const v_name = std::string(
"Vector_").append(typestr);
58 auto py_vect = py::bind_vector<Vector_type>(m, v_name.c_str());
61 [typestr](Vector_type
const & v) {
62 std::stringstream s, rs;
64 rs <<
"<amrex.Vector of type '" + typestr +
65 "' and size '" + s.str() +
"'>\n";
67 for (
int ii = 0; ii <
int(v.size()); ii++) {
75 .def(py::init<Vector_type const &>())
77 .def(
"size", &Vector_type::size)
80 if constexpr(std::is_fundamental_v<T>)
83 .def_property_readonly(
"__array_interface__", [](Vector_type
const & vector) {
86 .def_property_readonly(
"__cuda_array_interface__", [](Vector_type
const & vector) {
102 d[
"stream"] = py::none();
111 .def(
"__setitem__", [](Vector_type & vector,
int const idx, T
const value){ vector[idx] = value; })
112 .def(
"__getitem__", [](Vector_type & v,
int const idx){
return v[idx]; })
void make_Vector(py::module &m, std::string typestr)
Definition: Vector.H:51
Long size() const noexcept
py::dict array_interface(Array4< T > const &a4)
Definition: Array4.H:62