summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@gmail.com>2023-03-12 22:01:22 +0000
committerRalf Gommers <ralf.gommers@gmail.com>2023-03-12 22:31:28 +0000
commit1da1663196c95b3811ca84d9e335f32cfeb05e32 (patch)
treee6d432a66dd5c16051a4e1a400567b100200639a /numpy/core
parentac6233b03df6562453ebda984f565f603e726710 (diff)
downloadnumpy-1da1663196c95b3811ca84d9e335f32cfeb05e32.tar.gz
MAINT: remove `NUMPY_EXPERIMENTAL_ARRAY_FUNCTION` env var
As discussed in https://mail.python.org/archives/list/numpy-discussion@python.org/thread/UKZJACAP5FUG7KP2AQDPE4P5ADNWLOHZ/ This flag was always meant to be temporary, and cleaning it up is long overdue.
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/fromnumeric.py20
-rw-r--r--numpy/core/overrides.py14
-rw-r--r--numpy/core/shape_base.py11
-rw-r--r--numpy/core/tests/test_overrides.py19
4 files changed, 2 insertions, 62 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index 196ba5ea7..b36667427 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -3830,10 +3830,6 @@ def round_(a, decimals=0, out=None):
--------
around : equivalent function; see for details.
"""
- if not overrides.ARRAY_FUNCTION_ENABLED:
- # call dispatch helper explicitly, as it emits a deprecation warning
- _round__dispatcher(a, decimals=decimals, out=out)
-
return around(a, decimals=decimals, out=out)
@@ -3859,10 +3855,6 @@ def product(*args, **kwargs):
--------
prod : equivalent function; see for details.
"""
- if not overrides.ARRAY_FUNCTION_ENABLED:
- # call dispatch helper explicitly, as it emits a deprecation warning
- _product_dispatcher(*args, **kwargs)
-
return prod(*args, **kwargs)
@@ -3887,10 +3879,6 @@ def cumproduct(*args, **kwargs):
--------
cumprod : equivalent function; see for details.
"""
- if not overrides.ARRAY_FUNCTION_ENABLED:
- # call dispatch helper explicitly, as it emits a deprecation warning
- _cumproduct_dispatcher(*args, **kwargs)
-
return cumprod(*args, **kwargs)
@@ -3918,10 +3906,6 @@ def sometrue(*args, **kwargs):
--------
any : equivalent function; see for details.
"""
- if not overrides.ARRAY_FUNCTION_ENABLED:
- # call dispatch helper explicitly, as it emits a deprecation warning
- _sometrue_dispatcher(*args, **kwargs)
-
return any(*args, **kwargs)
@@ -3946,8 +3930,4 @@ def alltrue(*args, **kwargs):
--------
numpy.all : Equivalent function; see for details.
"""
- if not overrides.ARRAY_FUNCTION_ENABLED:
- # call dispatch helper explicitly, as it emits a deprecation warning
- _alltrue_dispatcher(*args, **kwargs)
-
return all(*args, **kwargs)
diff --git a/numpy/core/overrides.py b/numpy/core/overrides.py
index e93ef5d88..6403e65b0 100644
--- a/numpy/core/overrides.py
+++ b/numpy/core/overrides.py
@@ -11,9 +11,6 @@ from numpy.core._multiarray_umath import (
ARRAY_FUNCTIONS = set()
-ARRAY_FUNCTION_ENABLED = bool(
- int(os.environ.get('NUMPY_EXPERIMENTAL_ARRAY_FUNCTION', 1)))
-
array_function_like_doc = (
"""like : array_like, optional
Reference object to allow the creation of arrays which are not
@@ -140,17 +137,8 @@ def array_function_dispatch(dispatcher=None, module=None, verify=True,
Returns
-------
Function suitable for decorating the implementation of a NumPy function.
- """
-
- if not ARRAY_FUNCTION_ENABLED:
- def decorator(implementation):
- if docs_from_dispatcher:
- add_docstring(implementation, dispatcher.__doc__)
- if module is not None:
- implementation.__module__ = module
- return implementation
- return decorator
+ """
def decorator(implementation):
if verify:
if dispatcher is not None:
diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py
index 56c5a70f2..250fffd42 100644
--- a/numpy/core/shape_base.py
+++ b/numpy/core/shape_base.py
@@ -283,9 +283,6 @@ def vstack(tup, *, dtype=None, casting="same_kind"):
[6]])
"""
- if not overrides.ARRAY_FUNCTION_ENABLED:
- # reject non-sequences (and make tuple)
- tup = _arrays_for_stack_dispatcher(tup)
arrs = atleast_2d(*tup)
if not isinstance(arrs, list):
arrs = [arrs]
@@ -352,10 +349,6 @@ def hstack(tup, *, dtype=None, casting="same_kind"):
[3, 6]])
"""
- if not overrides.ARRAY_FUNCTION_ENABLED:
- # reject non-sequences (and make tuple)
- tup = _arrays_for_stack_dispatcher(tup)
-
arrs = atleast_1d(*tup)
if not isinstance(arrs, list):
arrs = [arrs]
@@ -447,10 +440,6 @@ def stack(arrays, axis=0, out=None, *, dtype=None, casting="same_kind"):
[3, 6]])
"""
- if not overrides.ARRAY_FUNCTION_ENABLED:
- # reject non-sequences (and make tuple)
- arrays = _arrays_for_stack_dispatcher(arrays)
-
arrays = [asanyarray(arr) for arr in arrays]
if not arrays:
raise ValueError('need at least one array to stack')
diff --git a/numpy/core/tests/test_overrides.py b/numpy/core/tests/test_overrides.py
index 90d917701..ae4cddb0e 100644
--- a/numpy/core/tests/test_overrides.py
+++ b/numpy/core/tests/test_overrides.py
@@ -10,16 +10,11 @@ from numpy.testing import (
assert_, assert_equal, assert_raises, assert_raises_regex)
from numpy.core.overrides import (
_get_implementing_args, array_function_dispatch,
- verify_matching_signatures, ARRAY_FUNCTION_ENABLED)
+ verify_matching_signatures)
from numpy.compat import pickle
import pytest
-requires_array_function = pytest.mark.skipif(
- not ARRAY_FUNCTION_ENABLED,
- reason="__array_function__ dispatch not enabled.")
-
-
def _return_not_implemented(self, *args, **kwargs):
return NotImplemented
@@ -150,7 +145,6 @@ class TestGetImplementingArgs:
class TestNDArrayArrayFunction:
- @requires_array_function
def test_method(self):
class Other:
@@ -209,7 +203,6 @@ class TestNDArrayArrayFunction:
args=(array,), kwargs={})
-@requires_array_function
class TestArrayFunctionDispatch:
def test_pickle(self):
@@ -249,7 +242,6 @@ class TestArrayFunctionDispatch:
dispatched_one_arg(array)
-@requires_array_function
class TestVerifyMatchingSignatures:
def test_verify_matching_signatures(self):
@@ -302,7 +294,6 @@ def _new_duck_type_and_implements():
return (MyArray, implements)
-@requires_array_function
class TestArrayFunctionImplementation:
def test_one_arg(self):
@@ -472,7 +463,6 @@ class TestNumPyFunctions:
signature = inspect.signature(np.sum)
assert_('axis' in signature.parameters)
- @requires_array_function
def test_override_sum(self):
MyArray, implements = _new_duck_type_and_implements()
@@ -482,7 +472,6 @@ class TestNumPyFunctions:
assert_equal(np.sum(MyArray()), 'yes')
- @requires_array_function
def test_sum_on_mock_array(self):
# We need a proxy for mocks because __array_function__ is only looked
@@ -503,7 +492,6 @@ class TestNumPyFunctions:
np.sum, (ArrayProxy,), (proxy,), {})
proxy.value.__array__.assert_not_called()
- @requires_array_function
def test_sum_forwarding_implementation(self):
class MyArray(np.ndarray):
@@ -555,7 +543,6 @@ class TestArrayLike:
def func_args(*args, **kwargs):
return args, kwargs
- @requires_array_function
def test_array_like_not_implemented(self):
self.add_method('array', self.MyArray)
@@ -588,7 +575,6 @@ class TestArrayLike:
@pytest.mark.parametrize('function, args, kwargs', _array_tests)
@pytest.mark.parametrize('numpy_ref', [True, False])
- @requires_array_function
def test_array_like(self, function, args, kwargs, numpy_ref):
self.add_method('array', self.MyArray)
self.add_method(function, self.MyArray)
@@ -621,7 +607,6 @@ class TestArrayLike:
@pytest.mark.parametrize('function, args, kwargs', _array_tests)
@pytest.mark.parametrize('ref', [1, [1], "MyNoArrayFunctionArray"])
- @requires_array_function
def test_no_array_function_like(self, function, args, kwargs, ref):
self.add_method('array', self.MyNoArrayFunctionArray)
self.add_method(function, self.MyNoArrayFunctionArray)
@@ -663,7 +648,6 @@ class TestArrayLike:
assert type(array_like) is self.MyArray
assert array_like.function is self.MyArray.fromfile
- @requires_array_function
def test_exception_handling(self):
self.add_method('array', self.MyArray, enable_value_error=True)
@@ -692,7 +676,6 @@ class TestArrayLike:
assert_equal(array_like, expected)
-@requires_array_function
def test_function_like():
# We provide a `__get__` implementation, make sure it works
assert type(np.mean) is np.core._multiarray_umath._ArrayFunctionDispatcher