| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Missing a test for BBoxHierarchy.search (or something in test_picture if you touches src/skia/Pictures.cpp? Also, this is the sort of information that should be in the commit message itself. (Try to keep the commit self-contained without requiring reading this pull message.) . On the command line, it is git commit --amend to edit the commit message of the commit you just made, or git rebase -i ..., then choose to "re-write", for older commits, before pushing. |
Sorry, something went wrong.
|
BBoxHierarchy.search is a virtual method, I have no idea how to test it. |
Sorry, something went wrong.
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 BBoxHierarchy.search so either that's a mistake (not invokable, and should be removed) or should be tested... I think it should be invokable if not directly. 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. |
Sorry, something went wrong.
|
I found there is a RTreeFactory class that can generate RTree class, which is derived from BBoxHierarchy. It can be used for test. |
Sorry, something went wrong.
That's probably correct - RTreeFactory.seach or something derived might be invokable. |
Sorry, something went wrong.
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. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
https://github.com/kyamagu/skia-python/blob/832cb4e733548dedc6fa93f59066e149329ba4d3/src/skia/Picture.cpp#L30-L35
|
Sorry, something went wrong.
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++. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
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: std::vector<int> search(const& query) {
std::vector<int> result;
this->search(query, &result);
return result;
}
|
Sorry, something went wrong.
This looks better. Should I modify this in this PR? Or you will modify it? |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
pybind11 cannot fill an input pointer with fetched stuff. See skia-python#263
|
I've modified the API and tests, |
Sorry, something went wrong.
|
The pybind11::gil_scoped_acquire gil; looks a bit dubious? 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). |
Sorry, something went wrong.
|
I followed the example in https://pybind11.readthedocs.io/en/stable/advanced/classes.html#different-method-signatures The class PyBBoxHierarchy is a 'trampoline' for overriding virtual functions in Python. |
Sorry, something went wrong.
|
The adjustment in PyBBoxHierarchy is for extending BBoxHierarchy in python, it's different from the signature override in https://github.com/MeetWq/skia-python/blob/ffcb64e5ba33f2aaf64d4de1ab9801398ce188bb/src/skia/Picture.cpp#L328 |
Sorry, something went wrong.
|
I am still going to ask why those pybind11::gil_scoped_acquire gil; are there? |
Sorry, something went wrong.
|
As in https://pybind11.readthedocs.io/en/stable/advanced/misc.html#global-interpreter-lock-gil
There is a pybind11::gil_scoped_acquire gil; expression inside the macro PYBIND11_OVERLOAD_PURE also. Maybe py::gil_scoped_release release; should also be explicitly called as shown in the example. |
Sorry, something went wrong.
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...). |
Sorry, something went wrong.
It was deleted by mistake
port 3 tests `Picture_fillsBBH`, `PictureNegativeSpace` and `Picture_SkipBBH` from google/skia
| Back | FazBrowse Home | New Git URL |
There are arguments with type std::vector in Point.Offset and BBoxHierarchy.search, but forget to #include <pybind11/stl.h>.
A test test_Point_Offset is added, it will fail without the include.
__________________________________________________ test_Point_Offset ___________________________________________________ def test_Point_Offset(): points = [skia.Point(1, 2), skia.Point(3, 4)] > points = skia.Point.Offset(points, 1, 1) E TypeError: Offset(): incompatible function arguments. The following argument types are supported: E 1. (points: std::vector<SkPoint, std::allocator<SkPoint> >, offset: skia.Point) -> std::vector<SkPoint, std::allocator<SkPoint> > E 2. (points: std::vector<SkPoint, std::allocator<SkPoint> >, dx: float, dy: float) -> std::vector<SkPoint, std::allocator<SkPoint> > E E Invoked with: [Point(1, 2), Point(3, 4)], 1, 1 E E Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>, E <pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic E conversions are optional and require extra headers to be included E when compiling your pybind11 module.