8000 ENH: Validate dispatcher functions in array_function_dispatch by shoyer · Pull Request #12099 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Validate dispatcher functions in array_function_dispatch #12099

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 3 commits into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Change verify_signature keyword argument to verify
  • Loading branch information
shoyer committed Oct 8, 2018
commit 7bd71e515db6622644e21a6e623d9ab5aa5d2720
4 changes: 2 additions & 2 deletions numpy/core/overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ def verify_matching_signatures(implementation, dispatcher):
'default argument values')


def array_function_dispatch(dispatcher, check_signature=True):
def array_function_dispatch(dispatcher, verify=True):
"""Decorator for adding dispatch with the __array_function__ protocol."""
def decorator(implementation):
# TODO: only do this check when the appropriate flag is enabled or for
# a dev install. We want this check for testing but don't want to
# slow down all numpy imports.
if check_signature:
if verify:
verify_matching_signatures(implementation, dispatcher)

@functools.wraps(implementation)
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/tests/test_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def f(y):
pass

# should not raise
@array_function_dispatch(lambda x: (x,), check_signature=False)
@array_function_dispatch(lambda x: (x,), verify=False)
def f(y):
pass

Expand Down
0