From be1b1932f73fb5946b4867337ba2fd2d31964d11 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Wed, 20 Jan 2021 16:11:17 -0700 Subject: Add type annotations to the array api submodule function definitions Some stubs still need to be modified to properly pass mypy type checking. Also, 'device' is just left as a TypeVar() for now. --- numpy/_array_api/_utility_functions.py | 8 ++++++-- 1 file changed, 6 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 19743d15c..69e17e0e5 100644 --- a/numpy/_array_api/_utility_functions.py +++ b/numpy/_array_api/_utility_functions.py @@ -1,6 +1,10 @@ +from __future__ import annotations + +from ._types import Optional, Tuple, Union, array + import numpy as np -def all(x, /, *, axis=None, keepdims=False): +def all(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array: """ Array API compatible wrapper for :py:func:`np.all `. @@ -8,7 +12,7 @@ def all(x, /, *, axis=None, keepdims=False): """ return np.all(x, axis=axis, keepdims=keepdims) -def any(x, /, *, axis=None, keepdims=False): +def any(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array: """ Array API compatible wrapper for :py:func:`np.any `. -- cgit v1.2.1