Skip to content

Commit 73dbcb5

Browse files
authored
Move broadcast functions to list of functions for manipulating arrays (#426)
* Move broadcast functions to list of functions for manipulating arrays * Fix list of exports
1 parent 965aac9 commit 73dbcb5

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

Diff for: spec/API_specification/data_type_functions.rst

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ Objects in API
1919
:template: method.rst
2020

2121
astype
22-
broadcast_arrays
23-
broadcast_to
2422
can_cast
2523
finfo
2624
iinfo

Diff for: spec/API_specification/manipulation_functions.rst

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Objects in API
2121
:toctree: generated
2222
:template: method.rst
2323

24+
broadcast_arrays
25+
broadcast_to
2426
concat
2527
expand_dims
2628
flip

Diff for: spec/API_specification/signatures/data_type_functions.py

+2-34
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ._types import List, Tuple, Union, array, dtype, finfo_object, iinfo_object
1+
from ._types import Union, array, dtype, finfo_object, iinfo_object
22

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

30-
def broadcast_arrays(*arrays: array) -> List[array]:
31-
"""
32-
Broadcasts one or more arrays against one another.
33-
34-
Parameters
35-
----------
36-
arrays: array
37-
an arbitrary number of to-be broadcasted arrays.
38-
39-
Returns
40-
-------
41-
out: List[array]
42-
a list of broadcasted arrays. Each array must have the same shape. Each array must have the same dtype as its corresponding input array.
43-
"""
44-
45-
def broadcast_to(x: array, /, shape: Tuple[int, ...]) -> array:
46-
"""
47-
Broadcasts an array to a specified shape.
48-
49-
Parameters
50-
----------
51-
x: array
52-
array to broadcast.
53-
shape: Tuple[int, ...]
54-
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.
55-
56-
Returns
57-
-------
58-
out: array
59-
an array having a specified shape. Must have the same data type as ``x``.
60-
"""
61-
6230
def can_cast(from_: Union[dtype, array], to: dtype, /) -> bool:
6331
"""
6432
Determines if one data type can be cast to another data type according :ref:`type-promotion` rules.
@@ -156,4 +124,4 @@ def result_type(*arrays_and_dtypes: Union[array, dtype]) -> dtype:
156124
the dtype resulting from an operation involving the input arrays and dtypes.
157125
"""
158126

159-
__all__ = ['astype', 'broadcast_arrays', 'broadcast_to', 'can_cast', 'finfo', 'iinfo', 'result_type']
127+
__all__ = ['astype', 'can_cast', 'finfo', 'iinfo', 'result_type']

Diff for: spec/API_specification/signatures/manipulation_functions.py

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
from ._types import List, Optional, Tuple, Union, array
22

3+
def broadcast_arrays(*arrays: array) -> List[array]:
4+
"""
5+
Broadcasts one or more arrays against one another.
6+
7+
Parameters
8+
----------
9+
arrays: array
10+
an arbitrary number of to-be broadcasted arrays.
11+
12+
Returns
13+
-------
14+
out: List[array]
15+
a list of broadcasted arrays. Each array must have the same shape. Each array must have the same dtype as its corresponding input array.
16+
"""
17+
18+
def broadcast_to(x: array, /, shape: Tuple[int, ...]) -> array:
19+
"""
20+
Broadcasts an array to a specified shape.
21+
22+
Parameters
23+
----------
24+
x: array
25+
array to broadcast.
26+
shape: Tuple[int, ...]
27+
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.
28+
29+
Returns
30+
-------
31+
out: array
32+
an array having a specified shape. Must have the same data type as ``x``.
33+
"""
34+
335
def concat(arrays: Union[Tuple[array, ...], List[array]], /, *, axis: Optional[int] = 0) -> array:
436
"""
537
Joins a sequence of arrays along an existing axis.
@@ -146,4 +178,4 @@ def stack(arrays: Union[Tuple[array, ...], List[array]], /, *, axis: int = 0) ->
146178
This specification leaves type promotion between data type families (i.e., ``intxx`` and ``floatxx``) unspecified.
147179
"""
148180

149-
__all__ = ['concat', 'expand_dims', 'flip', 'permute_dims', 'reshape', 'roll', 'squeeze', 'stack']
181+
__all__ = [ 'broadcast_arrays', 'broadcast_to', 'concat', 'expand_dims', 'flip', 'permute_dims', 'reshape', 'roll', 'squeeze', 'stack']

0 commit comments

Comments
 (0)