-
Notifications
You must be signed in to change notification settings - Fork 2.2k
PYBIND11_NUMPY_DTYPE does not work on structure containing array #800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's an intentional, explicit omission: not because it's impossible, but just because no one has done it yet. |
Well, almost... we wouldn't mark arrays as |
I don't think it's likely to conflict with int8_t[N], because int8_t will be I might have a go at it if I get time, although it won't be this week. |
This implements pybind#800. Both C++ arrays and std::array are supported, including mixtures like std::array<int, 2>[4]. In a multi-dimensional array of char, the last dimension is used to construct a numpy string type. There are some things I'm not sure about: - Is there a better name for array_info? The "array" could easily be misinterpreted as referring to py::array rather than std::array. - Should array_info be split into separate classes for the different traits, or is it okay to have this uber traits class? - When constructing the dtype, the shape should really be a tuple rather than a list, but I'm not sure how to dynamically construct a tuple (or how to convert the list to a tuple). numpy seems to accept a list. - Should the array dtypes be registered in some way? At present two structures embedding the same array type will each construct a separate dtype object to represent that array type. That's already the case for char[N] though. - Should I add tests to use an array type directly e.g. py::array_t<int[2]>?
Issue description
Using PYBIND11_NUMPY_DTYPE on a structure member which is an array (either a language array or
std::array
) leads to a compilation error:Reproducible example code
Compiled with GCC 5.4 with
g++ -std=c++14 -c pybind11-array.cpp
plus-I
options for Python and pybind11, and pybind11 version 2.1.1The text was updated successfully, but these errors were encountered: