summaryrefslogtreecommitdiff
path: root/numpy/core/shape_base.py
diff options
context:
space:
mode:
authorStephan Hoyer <shoyer@google.com>2018-10-26 08:20:26 -0700
committerStephan Hoyer <shoyer@google.com>2018-10-26 08:20:31 -0700
commit786cfa0d0d914c1438aa176b3d990d6cf75ea837 (patch)
tree15b9328cfa85d5a3ce463c6bc0299781ed3a4401 /numpy/core/shape_base.py
parent3debe9772ea1b68d997dba3440929a467ad11c52 (diff)
downloadnumpy-786cfa0d0d914c1438aa176b3d990d6cf75ea837.tar.gz
MAINT: set __module__ for more array_function_dispatch uses
I noticed a few more functions using ``array_function_dispatch`` where I had not set the module, using this script:: import types def check_module(module): for name in dir(module): item = getattr(module, name) if isinstance(item, types.FunctionType): print(f'{item.__module__}.{item.__name__}') >>> import numpy >>> check_module(numpy) ... Note that functions without overrides like ``numpy.ones`` still display the module in which they are defined, e.g., ``numpy.core.numeric.ones``. We should probably fix that, too, probably most cleanly adding a decorator that sets ``__module__``, e.g., def set_module(module): def decorator(func): func.__module__ = module return func return decorator ... @set_module('numpy') def ones(shape, dtype=None, order='C'): ...
Diffstat (limited to 'numpy/core/shape_base.py')
-rw-r--r--numpy/core/shape_base.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py
index c9f8ebccb..71a23f438 100644
--- a/numpy/core/shape_base.py
+++ b/numpy/core/shape_base.py
@@ -7,9 +7,13 @@ import functools
import operator
from . import numeric as _nx
+from . import overrides
from .numeric import array, asanyarray, newaxis
from .multiarray import normalize_axis_index
-from .overrides import array_function_dispatch
+
+
+array_function_dispatch = functools.partial(
+ overrides.array_function_dispatch, module='numpy')
def _atleast_1d_dispatcher(*arys):