Repository navigation
Add support for np.broadcast_arrays - #7660
Conversation
bfe955a to
a476255
Compare
|
PR is ready for review. @gmarkall, can you please change the label? |
stuartarchibald
left a comment
There was a problem hiding this comment.
Thanks for the patch, I've given this an initial review, the impl and testing look like they cover the use case broadcast_arrays() with one arg, but I think some refactoring could help further. Thanks again!
|
@stuartarchibald, when you have some time, can you update the label in this PR? |
stuartarchibald
left a comment
There was a problem hiding this comment.
Thanks for the patch. I've given this an initial review to provide some feedback and have left this inline. Once addressed I'd like to take another look to see if there's any corner cases that are potentially missing as the tests equivalent to those from NumPy seem to cover a lot of things but there may be some Numba specific issues. Thanks again!
|
@stuartarchibald, when you have some time, can you update the label in this PR? |
stuartarchibald
left a comment
There was a problem hiding this comment.
Thanks for the updates @guilhermeleobas. I've made a couple more remarks in relation to what is supported/not supported, please could you take a look? Many thanks.
stuartarchibald
left a comment
There was a problem hiding this comment.
Thanks for the update. There seems to be a remaining issue with handling tuples but otherwise this looks good.
| for idx, arg in enumerate(args): | ||
| if isinstance(arg, types.ArrayCompatible): | ||
| m = max(m, arg.ndim) | ||
| elif isinstance(arg, (types.Number, types.Boolean)): | ||
| m = max(m, 1) |
There was a problem hiding this comment.
This unfortunately doesn't work:
from numba import njit
import numpy as np
@njit
def foo(tupl):
return np.broadcast_arrays(tupl, tupl)
print(foo((1,2)))I think the issue is that this loop is not handling tuple types? Probably needs something like:
elif isinstance(arg, types.BaseTuple):
m = max(m, arg.count)?
|
Failure is not related to the changes introduced in this PR. |
stuartarchibald
left a comment
There was a problem hiding this comment.
Thanks for the update. One minor style alignment issue to fix, then will mark for merge.
Co-authored-by: stuartarchibald <stuartarchibald@users.noreply.github.com>
|
@stuartarchibald done! |
stuartarchibald
left a comment
There was a problem hiding this comment.
Thanks for the patch and fixes.
As title