Fix type confusion during downcastsing and add a test case showing how to extract an array from a dictionary.#265
Conversation
3a6dd6f to
f2ac1b1
Compare
|
@davidhewitt @kngwyu I think there is a serious type confusion bug present here. The test added here first failed with which is surprising as the downcast to I think the problem is again that instances of Lines 115 to 122 in 2da4787 npyffi::PyArray_Check which will therefore consider PyArray1<i32> and PyArray1<f64> to be the same type.
I tried to fix this by manually implementing |
f2ac1b1 to
4a95f1d
Compare
4a95f1d to
c8390e3
Compare
|
Oh no! |
davidhewitt
left a comment
There was a problem hiding this comment.
Yikes, good find!
Now that numpy isn't using the generics for native_type_info I'm definitely tempted to refactor the macros in PyO3. However I don't think we need to rush to do this, because when we try to implement owned PyAny (maybe in 0.17, finally) then we'll need to write a new set of macros anyway. So might as well leave these ones as-is for now.
If rust-numpy is the only reason this macro supports generics, then I'd suggest removing as they are a bit of a foot gun. I don''t think it can be correctly implemented without access to the type arguments and their bounds. (Tricks like Downstreams like us who do want to do this should go the manual route so they double-check everything. But then again, the macro itself is not really public documented API in the first place, isn't it? |
Fixes #242