-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat: modify VectorInit to handle numpy multi dimensional arrays #28
Conversation
Two points: first, don't change comment indentation (I know the style is a bit unusual, but the reason for it is that it makes super-easy to read either the code or the comments, instead of having both in the same flow) and don't remove white lines if it changes the style. Second, as discussed, the NumPy folks designed the "new-style" buffer protocol: https://docs.python.org/3/c-api/buffer.html . There are examples of its use in As for the use of creating the |
Code doesn't execute due to `PyObject_GetBuffer` non-matching function call, even though it is correct way as per the numpy buffer protocol docs
Code executes but Pycode return an error to handle TemplateProxy
Logic to implement the initialisation still remains
It results in TypeError: a bytes-like object is required, not 'cppyy.TemplateProxy'
e249453
to
2d5f981
Compare
@@ -52,6 +52,24 @@ bool HasAttrDirect(PyObject* pyclass, PyObject* pyname, bool mustBeCPyCppyy = fa | |||
return false; | |||
} | |||
|
|||
template <typename T> | |||
T Get_IndexValue(Py_buffer *view, int i) |
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.
T Get_IndexValue(Py_buffer *view, int i) | |
bool Get_IndexValue(Py_buffer *view, T* value) |
for (Py_ssize_t i = 0; i < fillsz; i++) | ||
{ | ||
int val = Get_IndexValue<int>(view, i); | ||
PyObject *item = PyLong_FromLong(val); |
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.
Mapping of view->format
to typename (e.g. 'i'
-> 'int
'; see low-level view type_traits).
TConverter* conv = CreateConverter(type_returned);
PyObject* item = conv->FromMemory(view->buf + i*view->itemsize);
if (conv->HasState()) delete conv;
Implemented this PR logic in cppyy (frontend) - cppyy#255 instead |
No description provided.