-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Expose a few ArrayDescriptor properties and option for mutable flags #4451
base: master
Are you sure you want to change the base?
Conversation
include/pybind11/numpy.h
Outdated
#if defined(_MSC_VER) | ||
# pragma warning(push) | ||
# pragma warning(disable : 4127) // warning C4127: Conditional expression is constant | ||
typedef SSIZE_T ssize_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, why is this typedef necessary?
include/pybind11/numpy.h
Outdated
@@ -18,6 +18,7 @@ | |||
#include <cstdlib> | |||
#include <cstring> | |||
#include <functional> | |||
#include <iostream> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for iostream include
rm old code from npe
whoops, had some old code remaining from my fork that I forgot to remove. Fixed this. |
@fwilliams could you please add tests for the new methods? Especially the mutable I had a quick look here: https://numpy.org/doc/stable/reference/generated/numpy.ndarray.flags.html What stands out to me:
My gut feeling is that it would be safer not to expose the direct mutable reference, but to add
That sounds very dangerous (bug prone) and would need careful explanation and unit testing. |
rm old code from npe
Zg/sync pybind11
Description
This change exposes a few elements in the
PyArrayDescr
struct which I am using in another project.It also exposes a mutable version of
flags()
inpybind11::array()
, which is useful when you need to steal the memory from a numpy array accross python calls.