diff options
author | Stephan Hoyer <shoyer@google.com> | 2019-05-25 15:05:59 -0700 |
---|---|---|
committer | Stephan Hoyer <shoyer@google.com> | 2019-05-25 15:05:59 -0700 |
commit | 766281d1bef8845407855ddf48e3d6b50668e7b7 (patch) | |
tree | 1819782e20975fd6abab3f4513d8a4c717ec4cd6 /numpy/core/overrides.py | |
parent | cf704e7f245e89c623bd82cbdba7c2dd07cf5fb4 (diff) | |
download | numpy-766281d1bef8845407855ddf48e3d6b50668e7b7.tar.gz |
MAINT: revert __skip_array_function__ from NEP-18
xref GH-13624, GH-12028
TODO: update tests/CI for NUMPY_EXPERIMENTAL_ARRAY_FUNCTION=0
Diffstat (limited to 'numpy/core/overrides.py')
-rw-r--r-- | numpy/core/overrides.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/numpy/core/overrides.py b/numpy/core/overrides.py index ad4d1c721..347e71bd4 100644 --- a/numpy/core/overrides.py +++ b/numpy/core/overrides.py @@ -1,6 +1,7 @@ """Implementation of __array_function__ overrides from NEP-18.""" import collections import functools +import os import textwrap from numpy.core._multiarray_umath import ( @@ -8,6 +9,10 @@ from numpy.core._multiarray_umath import ( from numpy.compat._inspect import getargspec +ENABLE_ARRAY_FUNCTION = bool( + int(os.environ.get('NUMPY_EXPERIMENTAL_ARRAY_FUNCTION', 1))) + + add_docstring( implement_array_function, """ @@ -137,6 +142,22 @@ def array_function_dispatch(dispatcher, module=None, verify=True, Function suitable for decorating the implementation of a NumPy function. """ + if not ENABLE_ARRAY_FUNCTION: + def decorator(implementation): + if docs_from_dispatcher: + add_docstring(implementation, dispatcher.__doc__) + + public_api = implementation + + if module is not None: + public_api.__module__ = module + + public_api._implementation = implementation + + return public_api + + return decorator + def decorator(implementation): if verify: verify_matching_signatures(implementation, dispatcher) @@ -172,7 +193,7 @@ def array_function_dispatch(dispatcher, module=None, verify=True, if module is not None: public_api.__module__ = module - public_api.__skip_array_function__ = implementation + public_api._implementation = implementation return public_api |