Skip to content

Commit 2056a94

Browse files
authored
Fix optional keyword argument in take signature (#644)
This commit fixes the function signature for `take`. Namely, when an input array is one-dimensional, the `axis` kwarg is optional; when the array has more than one dimension, the `axis` kwarg is required. Unfortunately, the type signature cannot encode this duality, and we must rely on the specification text to clarify that the `axis` kwarg is required for arrays having ranks greater than unity. Ref: data-apis/array-api-compat#34
1 parent 2e0c414 commit 2056a94

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: src/array_api_stubs/_2022_12/indexing_functions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from ._types import Union, array
1+
from ._types import Union, Optional, array
22

33

4-
def take(x: array, indices: array, /, *, axis: int) -> array:
4+
def take(x: array, indices: array, /, *, axis: Optional[int] = None) -> array:
55
"""
66
Returns elements of an array along an axis.
77

Diff for: src/array_api_stubs/_draft/indexing_functions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from ._types import Union, array
1+
from ._types import Union, Optional, array
22

33

4-
def take(x: array, indices: array, /, *, axis: int) -> array:
4+
def take(x: array, indices: array, /, *, axis: Optional[int] = None) -> array:
55
"""
66
Returns elements of an array along an axis.
77

0 commit comments

Comments
 (0)