summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authoryuki <drsuaimqjgar@gmail.com>2023-03-22 01:16:42 +0000
committeryuki <drsuaimqjgar@gmail.com>2023-03-22 01:16:42 +0000
commit6f1679c48d19198273c02379acd68cb8c601d21e (patch)
treea912b119658a714524f57fc704695ded1738d8bb /numpy/lib/function_base.py
parent03edb7b8dddb12198509d2bf602ea8b382d27199 (diff)
parent294c7f2c893b7e5ef783fc1cb1912d06404b452b (diff)
downloadnumpy-6f1679c48d19198273c02379acd68cb8c601d21e.tar.gz
Merge branch 'main' into enh-ma-dot
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py33
1 files changed, 16 insertions, 17 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 405790025..f0f374f97 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -4910,23 +4910,22 @@ def trapz(y, x=None, dx=1.0, axis=-1):
return ret
-if overrides.ARRAY_FUNCTION_ENABLED:
- # If array-function is enabled (normal), we wrap everything into a C
- # callable, which has no __code__ or other attributes normal Python funcs
- # have. SciPy however, tries to "clone" `trapz` into a new Python function
- # which requires `__code__` and a few other attributes.
- # So we create a dummy clone and copy over its attributes allowing
- # SciPy <= 1.10 to work: https://github.com/scipy/scipy/issues/17811
- assert not hasattr(trapz, "__code__")
-
- def _fake_trapz(y, x=None, dx=1.0, axis=-1):
- return trapz(y, x=x, dx=dx, axis=axis)
-
- trapz.__code__ = _fake_trapz.__code__
- trapz.__globals__ = _fake_trapz.__globals__
- trapz.__defaults__ = _fake_trapz.__defaults__
- trapz.__closure__ = _fake_trapz.__closure__
- trapz.__kwdefaults__ = _fake_trapz.__kwdefaults__
+# __array_function__ has no __code__ or other attributes normal Python funcs we
+# wrap everything into a C callable. SciPy however, tries to "clone" `trapz`
+# into a new Python function which requires `__code__` and a few other
+# attributes. So we create a dummy clone and copy over its attributes allowing
+# SciPy <= 1.10 to work: https://github.com/scipy/scipy/issues/17811
+assert not hasattr(trapz, "__code__")
+
+def _fake_trapz(y, x=None, dx=1.0, axis=-1):
+ return trapz(y, x=x, dx=dx, axis=axis)
+
+
+trapz.__code__ = _fake_trapz.__code__
+trapz.__globals__ = _fake_trapz.__globals__
+trapz.__defaults__ = _fake_trapz.__defaults__
+trapz.__closure__ = _fake_trapz.__closure__
+trapz.__kwdefaults__ = _fake_trapz.__kwdefaults__
def _meshgrid_dispatcher(*xi, copy=None, sparse=None, indexing=None):