Skip to content
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

Merged
merged 12 commits into from Mar 14, 2019
Merged

Min max on iterables #3820

merged 12 commits into from Mar 14, 2019

Conversation

rjenc29
Copy link
Contributor

@rjenc29 rjenc29 commented Mar 3, 2019

Initial commit for CI. Addresses #3776

@rjenc29 rjenc29 changed the title Min max on iterables WIP: Min max on iterables Mar 3, 2019
@rjenc29
Copy link
Contributor Author

rjenc29 commented Mar 3, 2019

Well, that was somewhat less successful than I'd hoped.

I thought I'd tweak the overload implementation a little to support iterable types, but this breaks some of the parallel implementations.

Perhaps tweaking the overload implementation isn't such a good idea. Let me know what you think if you get a mo.

@stuartarchibald
Copy link
Contributor

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:

def indval_min(indval1, indval2=None):

one implementation has a matching signature:
def impl(indval1, indval2=None):

the other does not:
def impl(indval1, indval2):

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).

@rjenc29
Copy link
Contributor Author

rjenc29 commented Mar 5, 2019

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

@stuartarchibald
Copy link
Contributor

No problem, it's a new thing! It seems like this PR is along the right lines, thanks for continuing to work on it.

@rjenc29 rjenc29 changed the title WIP: Min max on iterables Min max on iterables Mar 8, 2019
@rjenc29
Copy link
Contributor Author

rjenc29 commented Mar 8, 2019

If you get a mo, could you let me know how you feel about this incarnation, TA!

Copy link
Contributor

@stuartarchibald stuartarchibald left a 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).

return impl

if indval2 is None:
if isinstance(indval1, types.IterableType):
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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,)])
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@stuartarchibald stuartarchibald added 4 - Waiting on author Waiting for author to respond to review and removed 3 - Ready for Review labels Mar 8, 2019
@stuartarchibald
Copy link
Contributor

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.

@stuartarchibald stuartarchibald added 5 - Ready to merge Review and testing done, is ready to merge and removed 4 - Waiting on author Waiting for author to respond to review labels Mar 12, 2019
@sklam sklam added this to Ready to Merge in Active Mar 14, 2019
@seibert seibert merged commit d277d92 into numba:master Mar 14, 2019
Active automation moved this from Ready to Merge to Done Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to merge Review and testing done, is ready to merge
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants