-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Allow std::complex field with PYBIND11_NUMPY_DTYPE #831
Commits on May 4, 2017
-
Allow std::complex field with PYBIND11_NUMPY_DTYPE
This exposed a few underlying issues: 1. is_pod_struct was too strict to allow this. I've relaxed it to require only trivially copyable and standard layout, rather than POD (which additionally requires a trivial constructor, which std::complex violates). Should the name be changed too? There might also need to be some documentation to warn the user not to do something stupid with a class that has invariants. 2. format_descriptor<std::complex<T>>::format() returned numpy format strings instead of PEP3118 format strings, but register_dtype feeds format codes of its fields to _dtype_from_pep3118. I've changed it to return PEP3118 format codes. format_descriptor is a public type, so this may be considered an incompatible change. 3. register_structured_dtype tried to be smart about whether to mark fields as unaligned (with ^). However, it's examining the C++ alignment, rather than what numpy (or possibly PEP3118) thinks the alignment should be. For complex values those are different. I've made it mark all fields as ^ unconditionally, which should always be safe even if they are aligned, because we explicitly mark the padding.
Configuration menu - View commit details
-
Copy full SHA for d383bd8 - Browse repository at this point
Copy the full SHA d383bd8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 51b51b6 - Browse repository at this point
Copy the full SHA 51b51b6View commit details -
Refinement to GCC 4 workaround
Require either a trivial copy constructor or a trivial copy assignment, but not both. This is slightly more relaxed than being TriviallyCopyable, which requires that both are either trivial or deleted, and that at least one is not deleted. With this check, one of them could be user-provided.
Configuration menu - View commit details
-
Copy full SHA for fb8a4ed - Browse repository at this point
Copy the full SHA fb8a4edView commit details -
Workaround for numpy/numpy#9049
This moves the ^ in the format string (to specify unaligned) to outside the `T{}` where it is sure to be parsed correctly. This is not strictly necessary yet, but it paves the way for pybind#832.
Configuration menu - View commit details
-
Copy full SHA for 271f380 - Browse repository at this point
Copy the full SHA 271f380View commit details
Commits on May 6, 2017
-
For some reason, returning the 'value' constexpr char array as a string would yield an empty string for format_descriptor<float>. I tried a few variants of the constructor and this is the first variation I found that worked.
Configuration menu - View commit details
-
Copy full SHA for c8f6488 - Browse repository at this point
Copy the full SHA c8f6488View commit details
Commits on May 8, 2017
-
Restructure format_descriptor overload for complex
At the request of @jagerman, a separate specialization of format_descriptor is implemented for std::complex. This may run into MSVC 2015 bugs again - will put back the workaround if it fails.
Configuration menu - View commit details
-
Copy full SHA for bd5be69 - Browse repository at this point
Copy the full SHA bd5be69View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0556c35 - Browse repository at this point
Copy the full SHA 0556c35View commit details -
Add documentation about what structured types are acceptable
This is to go with the weakened is_pod_struct static_assert.
Configuration menu - View commit details
-
Copy full SHA for f5818b4 - Browse repository at this point
Copy the full SHA f5818b4View commit details
Commits on May 10, 2017
-
Configuration menu - View commit details
-
Copy full SHA for 979d979 - Browse repository at this point
Copy the full SHA 979d979View commit details