Bugfix/matrix buffer protocol#498
Conversation
|
Hopefully failing tests here: https://github.com/willstott101/gz-math/actions/runs/3016276863 |
0eb7ec0 to
e0b8cd1
Compare
adityapande-1995
left a comment
There was a problem hiding this comment.
Hi ! Could you please add signoffs to your commits ? https://gazebosim.org/docs/all/contributing#contributing-code
|
I mentioned in the original PR text:
I'm not happy to sign this off yet so I won't sign off the commits. |
e0b8cd1 to
b793570
Compare
|
Takes a really long time for the CI to roll through, here's latest runs (since they're not allowed to run here by the looks of it?) Expected failing new tests: https://github.com/willstott101/gz-math/actions/runs/3016796871 |
a15db79 to
82b51bd
Compare
Since it was your first time contributing they had to be manually approved, they will run now (and I don't believe you need approval in the future) |
a2ccd2c to
909c46b
Compare
|
Ok finally happy (with everything but making
Resulting buffers are contiguous, index in the same way whether using numpy, memoryview, or This means we can go from Matrix -> flat list with () requires contiguous to cast: And matrix to structured list with (does not require contiguous): |
Did you have a workaround for this yet? |
|
Nope, I'm not much of a c++ guy, doubt I'll get to digging to be honest - but happy to update if someone has an idea |
|
I've had a bit of a dig into this, and I don't see any way to make the python binding have access to the private member. It just doesn't seem possible with the way the templates are used. I don't think making data public is all that bad, would you be tempted to accept this MR with making the data var public? |
Signed-off-by: Will Stott <willstott101@gmail.com>
Signed-off-by: Will Stott <willstott101@gmail.com>
Signed-off-by: Will Stott <willstott101@gmail.com>
02bfd3c to
a361471
Compare
|
I've signed off the commits |
|
How about using accessor functions? |
|
To what end? This PR is about exposing the underlying multi-dimensional array to python. Accessor functions won't enable that. The buffer protocol is commonly used for converting to/from numpy arrays for instance. I happen to be using it to get the data as a python list, though that could of course be done slowly with accessor functions, exposing the underlying data using the buffer protocol is more flexible, potentially faster in some scenarios and is very common for matrix/array programming in python. |
I would prefer adding an accessor method that returns the |
Codecov Report
@@ Coverage Diff @@
## gz-math7 #498 +/- ##
=========================================
Coverage 99.70% 99.70%
=========================================
Files 77 77
Lines 7007 7026 +19
=========================================
+ Hits 6986 7005 +19
Misses 21 21
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
I see, I hadn't considered deprecation processes. That makes sense, thank you for explaining. I understand there might be some hesitance with exposing the underlying array. Definitely rarely need to, particularly when used in a language with very fast (or even inlined) function calls. Sadly python isn't that :( Would the return type simply be Perhaps that would help reduce the likelyhood of using it incorrectly. And also make it easier to support a strongly-typed copying getter/setter pair if the reference returning method had to be deprecated. Either way I'm happy to update this MR with a reference/pointer returning method. |
|
Closing in favour of #524 |
Summary
Now:
Checklist
codecheckpassed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-bymessages.I haven't signed off yet cause I want feedback on making
datanon-private - is there another way to access that data from the python header - some sort offriendthing?