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
Min max on iterables #3820
Min max on iterables #3820
Conversation
Well, that was somewhat less successful than I'd hoped. I thought I'd tweak the Perhaps tweaking the |
Thanks for starting work on this fix. The code is largely failing because of a mismatch introduced between the typing and implementation signatures. Typing is declared here: numba/numba/targets/builtins.py Line 477 in 72241de
one implementation has a matching signature: numba/numba/targets/builtins.py Line 466 in 72241de
the other does not: numba/numba/targets/builtins.py Line 458 in 72241de
This section of the build log reports the issue, https://travis-ci.org/numba/numba/jobs/501035162#L3792-L3822, feedback on whether this is sufficiently useful is welcome (it's relatively new as a feature). |
My apologies, it's obvious now you point it out. It's a very useful feature and I am not sure how the logs could be any more useful / direct in this case - I guess as the test failure came from an unexpected place, I must have assumed something more sinister at work. Please could we just chalk this up to my daftness (there's a pattern developing here...). Anyway. the last commit is in the right ballpark - I need to sort out the tests and tidy up a bit and then I will un-WIP and invite for a review. Should be in the next few days. Cheers |
No problem, it's a new thing! It seems like this PR is along the right lines, thanks for continuing to work on it. |
If you get a mo, could you let me know how you feel about this incarnation, TA! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch. The impl looks good, but I wonder if it can be extracted from the current definition scope to improve clarity (see comments).
numba/targets/builtins.py
Outdated
return impl | ||
|
||
if indval2 is None: | ||
if isinstance(indval1, types.IterableType): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if it's possible to pull these out of this scope which has a non-intuitive signature? Would defining another overload like:
@overload(min)
def iterable_min(iterable):
if isinstance(iterable, types.IterableType):
def impl(iterable):
<details>
work? Could also close over the <
, >
operator to save duplication too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
numba/tests/test_builtins.py
Outdated
yield lambda: op([(3, 4), (1, 2)]) | ||
yield lambda: op(frange(1.1, 3.3, 0.1)) | ||
yield lambda: op([np.nan, -np.inf, np.inf, np.nan]) | ||
yield lambda: op([(1,), (1,), (1,)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps vary the tuple value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Thanks for the fixes, this seems good. Whilst the impl does not close over the comparison operation, the llvm inliner should manage to inline the declared function with no trouble. |
Initial commit for CI. Addresses #3776