mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 14:45:12 +00:00
Rename PYBIND11_DTYPE to PYBIND11_NUMPY_DTYPE
This commit is contained in:
parent
5afe9df30a
commit
5412a05cf0
@ -1362,7 +1362,7 @@ NumPy structured types
|
|||||||
======================
|
======================
|
||||||
|
|
||||||
In order for ``py::array_t`` to work with structured (record) types, we first need
|
In order for ``py::array_t`` to work with structured (record) types, we first need
|
||||||
to register the memory layout of the type. This can be done via ``PYBIND11_DTYPE``
|
to register the memory layout of the type. This can be done via ``PYBIND11_NUMPY_DTYPE``
|
||||||
macro which expects the type followed by field names:
|
macro which expects the type followed by field names:
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
@ -1377,8 +1377,8 @@ macro which expects the type followed by field names:
|
|||||||
A a;
|
A a;
|
||||||
};
|
};
|
||||||
|
|
||||||
PYBIND11_DTYPE(A, x, y);
|
PYBIND11_NUMPY_DTYPE(A, x, y);
|
||||||
PYBIND11_DTYPE(B, z, a);
|
PYBIND11_NUMPY_DTYPE(B, z, a);
|
||||||
|
|
||||||
/* now both A and B can be used as template arguments to py::array_t */
|
/* now both A and B can be used as template arguments to py::array_t */
|
||||||
|
|
||||||
|
@ -101,9 +101,9 @@ void print_dtypes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init_ex20(py::module &m) {
|
void init_ex20(py::module &m) {
|
||||||
PYBIND11_DTYPE(SimpleStruct, x, y, z);
|
PYBIND11_NUMPY_DTYPE(SimpleStruct, x, y, z);
|
||||||
PYBIND11_DTYPE(PackedStruct, x, y, z);
|
PYBIND11_NUMPY_DTYPE(PackedStruct, x, y, z);
|
||||||
PYBIND11_DTYPE(NestedStruct, a, b);
|
PYBIND11_NUMPY_DTYPE(NestedStruct, a, b);
|
||||||
|
|
||||||
m.def("create_rec_simple", &create_recarray<SimpleStruct>);
|
m.def("create_rec_simple", &create_recarray<SimpleStruct>);
|
||||||
m.def("create_rec_packed", &create_recarray<PackedStruct>);
|
m.def("create_rec_packed", &create_recarray<PackedStruct>);
|
||||||
|
@ -327,7 +327,7 @@ private:
|
|||||||
#define PYBIND11_MAP_LIST(f, t, ...) \
|
#define PYBIND11_MAP_LIST(f, t, ...) \
|
||||||
PYBIND11_EVAL (PYBIND11_MAP_LIST1 (f, t, __VA_ARGS__, (), 0))
|
PYBIND11_EVAL (PYBIND11_MAP_LIST1 (f, t, __VA_ARGS__, (), 0))
|
||||||
|
|
||||||
#define PYBIND11_DTYPE(Type, ...) \
|
#define PYBIND11_NUMPY_DTYPE(Type, ...) \
|
||||||
::pybind11::detail::npy_format_descriptor<Type>::register_dtype \
|
::pybind11::detail::npy_format_descriptor<Type>::register_dtype \
|
||||||
({PYBIND11_MAP_LIST (PYBIND11_FIELD_DESCRIPTOR, Type, __VA_ARGS__)})
|
({PYBIND11_MAP_LIST (PYBIND11_FIELD_DESCRIPTOR, Type, __VA_ARGS__)})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user