Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions spec/API_specification/data_type_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Objects in API
:template: method.rst

astype
broadcast_arrays
broadcast_to
can_cast
finfo
iinfo
Expand Down
2 changes: 2 additions & 0 deletions spec/API_specification/manipulation_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Objects in API
:toctree: generated
:template: method.rst

broadcast_arrays
broadcast_to
concat
expand_dims
flip
Expand Down
34 changes: 1 addition & 33 deletions spec/API_specification/signatures/data_type_functions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._types import List, Tuple, Union, array, dtype, finfo_object, iinfo_object
from ._types import Union, array, dtype, finfo_object, iinfo_object

def astype(x: array, dtype: dtype, /, *, copy: bool = True) -> array:
"""
Expand Down Expand Up @@ -27,38 +27,6 @@ def astype(x: array, dtype: dtype, /, *, copy: bool = True) -> array:
an array having the specified data type. The returned array must have the same shape as ``x``.
"""

def broadcast_arrays(*arrays: array) -> List[array]:
"""
Broadcasts one or more arrays against one another.

Parameters
----------
arrays: array
an arbitrary number of to-be broadcasted arrays.

Returns
-------
out: List[array]
a list of broadcasted arrays. Each array must have the same shape. Each array must have the same dtype as its corresponding input array.
"""

def broadcast_to(x: array, /, shape: Tuple[int, ...]) -> array:
"""
Broadcasts an array to a specified shape.

Parameters
----------
x: array
array to broadcast.
shape: Tuple[int, ...]
array shape. Must be compatible with ``x`` (see :ref:`broadcasting`). If the array is incompatible with the specified shape, the function should raise an exception.

Returns
-------
out: array
an array having a specified shape. Must have the same data type as ``x``.
"""

def can_cast(from_: Union[dtype, array], to: dtype, /) -> bool:
"""
Determines if one data type can be cast to another data type according :ref:`type-promotion` rules.
Expand Down
32 changes: 32 additions & 0 deletions spec/API_specification/signatures/manipulation_functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
from ._types import List, Optional, Tuple, Union, array

def broadcast_arrays(*arrays: array) -> List[array]:
"""
Broadcasts one or more arrays against one another.

Parameters
----------
arrays: array
an arbitrary number of to-be broadcasted arrays.

Returns
-------
out: List[array]
a list of broadcasted arrays. Each array must have the same shape. Each array must have the same dtype as its corresponding input array.
"""

def broadcast_to(x: array, /, shape: Tuple[int, ...]) -> array:
"""
Broadcasts an array to a specified shape.

Parameters
----------
x: array
array to broadcast.
shape: Tuple[int, ...]
array shape. Must be compatible with ``x`` (see :ref:`broadcasting`). If the array is incompatible with the specified shape, the function should raise an exception.

Returns
-------
out: array
an array having a specified shape. Must have the same data type as ``x``.
"""

def concat(arrays: Union[Tuple[array, ...], List[array]], /, *, axis: Optional[int] = 0) -> array:
"""
Joins a sequence of arrays along an existing axis.
Expand Down