-
Notifications
You must be signed in to change notification settings - Fork 45
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
add missing pybind11 include #263
base: main
Are you sure you want to change the base?
Conversation
Missing a test for |
|
There are arguments of type `std::vector` in `Point.Offset` (located in the file `src/skia/Point.cpp`) and `BBoxHierarchy.search` (located in the file `src/skia/Picture.cpp`), but the corresponding files do not include `#include <pybind11/stl.h>`. Add the include statement and supplement with related tests.
We have code that binds The editing was a suggestion - it would be nice to include that info (in a future commit in this pull in particular, and generally in future contributions elsewhere), and there is a chance of adding that in a later / additional commit. Force-push on already public branches is a bit frowned upon, should be done only if the previous was a clear mistake - this wasn't a clear mistake, it was correct (as it seems) just somewhat incomplete. Anyway. |
I found there is a |
That's probably correct - |
Thanks for your suggestion, I just dont't want to have too many extra commits... Anyway, I've completed the commit message and test as you mentioned. |
For future maintenence, we don't want to accept large changes wholesale, with very brief / one-line message either :-). While I think you have a point of trying not too do too many small commits, I would generally say that, you will want to look at the commit in 6 months or a years' time (if there is a future problem), know which part to revert, and which part to fix, without ripping the whole thing with a single revert. |
skia-python/src/skia/Picture.cpp Lines 30 to 35 in 832cb4e
By the way, I'm confused about the signature of BBoxHierarchy.insert and BBoxHierarchy.search .When I testing the two methods, I found that:
|
The signature looks slightly wrong - there are some subtlety in passing a pointer to a list between c++ and python - the length info is lost on the way. I think the code needs to be modified to receive a python list, extract the length and the pointer from the input object, before calling the skia c++. |
If you lose the length info on the way, on the skia side it knows about only one element, which is what you are observing. |
I think the skia-python code is at least for the search method looks wrong - pybind11 in general cannot fill an input pointer with fetched stuff, so the search method need to be adapted to something like this:
|
This looks better. Should I modify this in this PR? Or you will modify it? |
I found two usages of this API: And both of them are as I outlined. That said, I wonder if Google folks will change this as at some point (ie. How committed are they to keep it in the current form, or as public api, at all). So it looks like a bit more involved - not only adding a test, updating the API, and perhaps porting the latter above as an example. |
pybind11 cannot fill an input pointer with fetched stuff. See kyamagu#263
I've modified the API and tests, |
The Btw, the override is for the base class in c++. I think if the signature is plainly different, it is just another overloaded method, and can be added as such; the search result appearing as a pointer input to be written isn't likely to work, as you are passing a python object into c++ and wants the c++ code to modify the python object's content. (I mean if you change the signature, actually receiving a python object in the c++ code, it might work; but casted to a pointer to x, is expected to be "read-only" on the c++ side). |
I followed the example in https://pybind11.readthedocs.io/en/stable/advanced/classes.html#different-method-signatures The class |
The adjustment in |
I am still going to ask why those |
As in https://pybind11.readthedocs.io/en/stable/advanced/misc.html#global-interpreter-lock-gil
There is a Maybe |
I think the 3 tests can be appended verbatim as they are, to tests/test_picture.py? There are enough asserts etc inside to serve as 3 "composite" tests, if you don't feel like adding individual ones, or finding adding individual tests a bit tedious (I do find that tedious, myself...). |
It was deleted by mistake
port 3 tests `Picture_fillsBBH`, `PictureNegativeSpace` and `Picture_SkipBBH` from google/skia
There are arguments with type
std::vector
inPoint.Offset
andBBoxHierarchy.search
, but forget to#include <pybind11/stl.h>
.A test
test_Point_Offset
is added, it will fail without the include.