BUG: Fix in1d for empty integer array as input#21842
Conversation
|
Thanks @MilesCranmer. I think the API would be nicer if both |
|
Completely agree. I was thinking it might be better to submit a quick fix now to get rid of the bug, then work on a smarter fix later. |
|
I don't really see that the float error should not happen for empty arrays (i.e. I don't like a fast path), but of course passing |
|
Sooner is better, but I don't think we need to bother with multiple iterations of fixes. Instead of a hot fix, go straight for the smart fix. |
|
Could I do something like this at the start of the method, for all kind? if ar1.size == 0:
return np.array([], dtype=bool)
if ar2.size == 0:
return np.zeros_like(ar1, dtype=bool)With the corresponding inverse if inverse is true. |
|
The error is with |
|
It looks like you'll need to do something in that |
|
Okay I just put in the one for I put this fast path within the codeblock for What do you both think? |
|
(Ready for review) |
|
Looks good, lets just put it in to unbreak. The "interesting" case is always things like shapes. But that won't matter here. |
|
Awesome, thanks |
cc @seberg @WarrenWeckesser
This fixes the bug described on #21841 introduced by the PR #12065. It also adds a unit test for the bug.