-
Notifications
You must be signed in to change notification settings - Fork 208
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
added from_cpp() method for the Eigen::Ref type_caster #334
Conversation
@WKarel, could I ask you to take a look to see whether this change makes sense as-is, or whether there are dangers involved in passing references around like this? |
So this caster does not ensure that the returned object stays valid (it may in fact be invalid immediately), and passing an I think that one may similarly see handing over As clarified already in #330, the use case already works when using Apart from that, I would re-use How about some test cases? |
Thank you @WKarel 🙇 |
0d06d40
to
b515b1f
Compare
Additionally, I would at least remove the trailing return type declarations from castToRefVXi, castToRefCnstVXi, castToDRefCnstVXi, and castToRef03CnstVXi in test_eigen.cpp. |
When I remove the type declarations, the castToRefCnstVXi fails, as the current implementation of Another question, reusing the |
I suggested to remove these return type declarations as examples of how to test the new functionality, without thinking too much about it. Of course, if a np.ndarray of non-matching type is casted into a Ref<const ...>, then it owns the data it maps. And since it is a temporary in castToRefCnstVXi, the returned np.ndarray refers to memory that has been destroyed upon exit from that function. So I suggest you find other ways for testing. Concerning re-using MapCaster::from_cpp(), my idea was to create a temporary Map from the Ref in |
d753eb3
to
710d09c
Compare
A small amount of duplication is fine for me here. |
@wjakob then everything should be ready for your review |
Merged, thanks! |
As discussed in issue #330, Eigen::Ref was missing the
from_cpp()
method in it's type caster. I essentially copied the from_cpp() method from the Eigen::Map type caster.