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

Multimethods for functional programming routines #65

Merged
merged 4 commits into from
Jul 23, 2020

Conversation

joaosferreira
Copy link
Collaborator

This PR adds multimethods that target functional programming routines. The multimethods are the following:

  • apply_along_axis
  • apply_over_axes
  • frompyfunc
  • piecewise

Notes:

  1. The only multimethod missing is vectorize which is actually a class so it needs to wait for Add overriding metaclass. #61 to be done and its changes are merged before it can be added.
  2. I've added onp.ufunc and da.ufunc.ufunc to the possible returned types in the tests. These are needed for testing the returned type of frompyfunc.

@joaosferreira joaosferreira changed the title Add multimethods on functional programming Multimethods for functional programming routines Jul 20, 2020
@joaosferreira
Copy link
Collaborator Author

I'm wondering if the items in piecewise's argument condlist should be dispatched given that they are boolean arrays.

@joaosferreira
Copy link
Collaborator Author

The default for apply_along_axis seems a bit complicated for now, I think I'll leave it for later.

@joaosferreira joaosferreira marked this pull request as ready for review July 20, 2020 17:11
def _piecewise_default(x, condlist, funclist, *args, **kw):
if not isinstance(condlist, list):
condlist = [condlist]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
condlist = [asarray(cond) for cond in condlist]

@hameerabbasi hameerabbasi merged commit 3a96c7a into Quansight-Labs:master Jul 23, 2020
joaosferreira added a commit to joaosferreira/unumpy that referenced this pull request Jul 23, 2020
@joaosferreira joaosferreira deleted the functional-routines branch July 23, 2020 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants