-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
ENH: Add __array_ufunc__
#8247
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
Merged
Merged
ENH: Add __array_ufunc__
#8247
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
4fd7e84
ENH: Revert "Temporarily disable __numpy_ufunc__"
charris fcd11d2
ENH: Rename __numpy_ufunc__ to __array_ufunc__.
charris c7b25e2
ENH: Remove position arg from __array_ufunc__.
charris 8a9e790
MAINT: Put PyArray_GetAttrString_SuppressException in get_attr_string.h
njsmith 4dd5380
MAINT: dike out a bunch of weird old code implementing scalar power
njsmith 7d9bc2f
BUG/ENH: Switch to simplified __array_ufunc__/binop interaction
njsmith e4b5163
MAINT: allow __array_ufunc__ = None to force binops to defer.
mhvk 2e6d8c0
MAINT: Split out C code in ufunc_override.h to .c file.
mhvk d5c5ac1
MAINT: Add NPY_NO_EXPORT modifier to PyUFunc_CheckOverride.
charris 3124e96
MAINT: for __array_ufunc__ pass inputs as *args, ensure out is tuple.
mhvk 6a3ca31
DOC: describe current implementation of __array_ufunc__.
mhvk 79bb733
DOC: Style and sphinx fixes for arrays.classes.rst.
charris 7c3dc5a
TST: test that gufuncs are also overridden by __array_ufunc__.
mhvk 71201d2
DOC: Describe __array_func__ in subclassing
mhvk 3041710
ENH: implement ndarray.__array_ufunc__
mhvk 5fe6fc6
DOC Update NEP to reflect actual implementation.
mhvk e092823
MAINT: let ndarray.__array_ufunc__ bail if any overrides are in place.
mhvk 1147894
MAINT: Update array_ufunc NEP.
pv e325a10
DOC: Document behavior of ufuncs with default ndarray.__array_ufunc__
pv 39c2273
DOC: Update ndarray.__array_ufunc__ documentation vs. review comments
pv 6b41d11
DOC: clarify use of super and getattr
mhvk 0ede0e9
DOC: update NEP again.
mhvk 5f9252c
DOC: implement many smaller and bigger changes suggested in review.
mhvk 8cc2f71
BUG,MAINT: ensure out=None is never passed on to __array_ufunc__.
mhvk 856da73
DOC: remove left-over piece discussing binops
mhvk 2b6c7fd
REVERT: remove __array_ufunc__ override for np.dot and ndarray.dot.
mhvk 36e8494
REVERT: remove __array_ufunc__ override for np.matmul.
mhvk 55500b9
MAINT: simplify now that __array_ufunc__ overrides ufuncs only.
mhvk 25e973d
MAINT: split out umath-specific part of ufunc_override.
mhvk b1fa10a
BUG: ensure subclass of override class doesn't segfault.
mhvk 1de8f5a
DOC: Mention `__array_ufunc__` in the 1.13.0 release notes.
charris a460015
DOC: ufunc-overrides: sync the discussion vs. current implementation
pv cd2e42c
DOC: ufunc-overrides: revise hierarchy discussion
pv ff628f1
BUG: Add back removed elision code.
charris 1fc6e63
DOC,TST: clarify example of ndarray subclass using __array_ufunc__
mhvk a431743
BUG: Support nout == 0 and at method
eric-wieser 1e460b7
DOC,MAINT: small corrections to NEP following Stephan's comments.
mhvk 02600d3
ENH: Add NDArrayOperatorsMixin mixin class.
shoyer d3ff023
DOC: clarify recommendations for subclasses, deprecations.
mhvk b9359f1
MAINT: remove unnecessary checks, wrong code for 'outer', cleanup.
mhvk 256a8ae
BUG: Fix ArrayLike(NDArrayOperatorsMixin) operations with object()
shoyer 3272a86
ENH: Better error message for __array_ufunc__ not implemented
shoyer 32221df
ENH: NDArrayOperatorsMixin calls ufuncs directly, like ndarray
shoyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
DOC,MAINT: small corrections to NEP following Stephan's comments.
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This needs to be updated: dispatch does not look at outputs anymore
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.
It does look at outputs! What it does not look at is any other optional arguments (in particular, it does not look at
where
).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.
Wait, really? Do we want that? I'm struggling to think of a use case, though I'm sure this has come up before.
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.
np.add(ndarray, ndarray, out=xarray)
? (Or sparse array, or dask array, etc.)Hopefully the semantics of the operation shouldn't change because of the presence of
out=
(that'd be a little to matlab-y for my taste ;-)), but the main function of__numpy_ufunc__
is find someone who knows how to iterate over all the containers involved, and being able to iterate over the output container is important.For the same reason I think it'd probably be nice to include
where=
in the dispatch, but we can always fix that in the future once it comes up.