Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd an example for sharing the memory buffer of the xarray between C++ and Python (numpy) #175
Conversation
|
I originally thought numpy view binding (#130) is necessary, but it turned out the feature I needed is already in the code base. |
|
Would someone be willing to take a look at this? If the fixes for pybind11 2.3 should be in a separate PR, I can close this and file two new ones. |
|
@yungyuc sorry for the late reply! I am looking at it now. |
| @@ -12,6 +12,7 @@ | |||
|
|
|||
| #include "pybind11/numpy.h" | |||
|
|
|||
| #include "xtensor/xarray.hpp" | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
yungyuc
Nov 5, 2018
Author
Contributor
Yes. On OSX if commenting it out, I got:
In file included from /Users/yungyuc/hack/code/xtensor-python/test/main.cpp:17:
In file included from /Users/yungyuc/hack/code/xtensor-python/include/xtensor-python/pyarray.hpp:17:
/Users/yungyuc/hack/usr/opt36_180914/include/xtensor/xiterator.hpp:406:25: error: no member named 'mpl' in namespace 'xtl'
return xtl::mpl::static_if<has_storage_iterator<C>::value>([&](auto self)
~~~~~^
This comment has been minimized.
This comment has been minimized.
SylvainCorlay
Nov 5, 2018
•
Member
Hum, this seems to be something that was fixed about 2 months ago in xtensor-stack/xtensor@8a61692.
This comment has been minimized.
This comment has been minimized.
yungyuc
Nov 6, 2018
•
Author
Contributor
You are right. I was testing against xtensor-stack/xtensor@18a26c8 (Fri Sep 14 15:55:58 2018 +0200). After updating xtensor to the latest master (xtensor-stack/xtensor@d61b71e) I don't need this line anymore. I'll remove it.
This comment has been minimized.
This comment has been minimized.
SylvainCorlay
Nov 6, 2018
Member
@yungyuc excellent!
(By the way, is there a specific reason why you are running on specific commits and not version tags?)
This comment has been minimized.
This comment has been minimized.
yungyuc
Nov 6, 2018
Author
Contributor
@SylvainCorlay It's only because of my careless practice. My time on my side project is limited so I am developing against master of primary dependencies (pybind11, xtensor, xtensor-python, etc.). It's fine but sometimes (like this time) I was distracted for weeks and forgot to update the dependencies.
Sorry for my silly mistake. I've add a new change reverting this line and other two spots of unnecessary change.
| @@ -8,11 +8,11 @@ | |||
|
|
|||
| #include "gtest/gtest.h" | |||
|
|
|||
| #include "xtensor-python/pyarray.hpp" | |||
This comment has been minimized.
This comment has been minimized.
| @@ -8,11 +8,11 @@ | |||
|
|
|||
| #include "gtest/gtest.h" | |||
|
|
|||
| #include "xtensor-python/pytensor.hpp" | |||
yungyuc commentedNov 2, 2018
#113 added the ability to take the memory buffer of an
xarrayand share it withndarrayin Python, but there wasn't an example for how to do it. This PR adds an example in the pytest directory.I also fixed some formatting and compatibilty issue with pybind11 2.3.