From ad19f7f7dfcfe33fd4591f1be3b4d9d30887899a Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Wed, 20 Jan 2021 17:57:10 -0700 Subject: Use np.asarray in the array API submodule for any function that can return a scalar This is needed to pass mypy type checks for the given type annotations. --- numpy/_array_api/_utility_functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'numpy/_array_api/_utility_functions.py') diff --git a/numpy/_array_api/_utility_functions.py b/numpy/_array_api/_utility_functions.py index 69e17e0e5..51a04dc8b 100644 --- a/numpy/_array_api/_utility_functions.py +++ b/numpy/_array_api/_utility_functions.py @@ -10,7 +10,7 @@ def all(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keep See its docstring for more information. """ - return np.all(x, axis=axis, keepdims=keepdims) + return np.asarray(np.all(x, axis=axis, keepdims=keepdims)) def any(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array: """ @@ -18,4 +18,4 @@ def any(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keep See its docstring for more information. """ - return np.any(x, axis=axis, keepdims=keepdims) + return np.asarray(np.any(x, axis=axis, keepdims=keepdims)) -- cgit v1.2.1