diff options
author | Peter Andreas Entschev <peter@entschev.com> | 2020-11-16 10:19:39 -0800 |
---|---|---|
committer | Peter Andreas Entschev <peter@entschev.com> | 2020-11-16 10:19:39 -0800 |
commit | adc261a50b11310c97ffbcf57d6e20a5980bfed9 (patch) | |
tree | 0ac71fd30678263d9a240a70cba7f30297123a62 /numpy/lib/twodim_base.py | |
parent | e0c9b265e171e92ee558c00712d1104e68f65c9b (diff) | |
download | numpy-adc261a50b11310c97ffbcf57d6e20a5980bfed9.tar.gz |
MAINT: Make like= in Python functions strict
Only allow objects that implement __array_function__
Diffstat (limited to 'numpy/lib/twodim_base.py')
-rw-r--r-- | numpy/lib/twodim_base.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py index 2b4cbdfbb..099fb2960 100644 --- a/numpy/lib/twodim_base.py +++ b/numpy/lib/twodim_base.py @@ -8,7 +8,9 @@ from numpy.core.numeric import ( asarray, where, int8, int16, int32, int64, empty, promote_types, diagonal, nonzero ) -from numpy.core.overrides import set_array_function_like_doc, set_module +from numpy.core.overrides import ( + array_function_dispatch_like, set_array_function_like_doc, set_module + ) from numpy.core import overrides from numpy.core import iinfo @@ -203,7 +205,15 @@ def eye(N, M=None, k=0, dtype=float, order='C', *, like=None): """ if like is not None: - return _eye_with_like(N, M=M, k=k, dtype=dtype, order=order, like=like) + return array_function_dispatch_like( + _eye_with_like, + N, + M=M, + k=k, + dtype=dtype, + order=order, + like=like + ) if M is None: M = N m = zeros((N, M), dtype=dtype, order=order) @@ -405,7 +415,9 @@ def tri(N, M=None, k=0, dtype=float, *, like=None): """ if like is not None: - return _tri_with_like(N, M=M, k=k, dtype=dtype, like=like) + return array_function_dispatch_like( + _tri_with_like, N, M=M, k=k, dtype=dtype, like=like + ) if M is None: M = N |