Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1acd41c

Browse files
committed
feat: addbroadcast_shapes to the specification
Ref:#893
1 parent6fd5129 commit1acd41c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

‎spec/draft/API_specification/manipulation_functions.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Objects in API
1919
:template: method.rst
2020

2121
broadcast_arrays
22+
broadcast_shapes
2223
broadcast_to
2324
concat
2425
expand_dims

‎src/array_api_stubs/_draft/manipulation_functions.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,35 @@ def broadcast_arrays(*arrays: array) -> List[array]:
3535
"""
3636

3737

38+
defbroadcast_shapes(*shapes:Tuple[int, ...])->Tuple[int, ...]:
39+
"""
40+
Broadcasts one or more shapes against one another.
41+
42+
Parameters
43+
----------
44+
shapes: Tuple[int, ...]
45+
an arbitrary number of to-be broadcasted shapes.
46+
47+
Returns
48+
-------
49+
out: Tuple[int, ...]
50+
a broadcasted shape.
51+
52+
Raises
53+
------
54+
ValueError
55+
If provided shapes which are not broadcast compatible (see :ref:`broadcasting`), a ``ValueError`` **should** be raised.
56+
57+
Notes
58+
-----
59+
60+
- If not provided one or more arguments, the function **must** return an empty tuple.
61+
62+
.. note::
63+
Array libraries which build computation graphs (e.g., ndonnx and Dask) commonly support shapes having dimensions of unknown size. If a shape contains a value other than an integer (e.g., ``None`` for a dimension of unknown size), behavior is unspecified and thus implementation-defined. Array-conforming libraries **may** choose to propagate such values (e.g., if a shape contains a dimension size of ``None``, the returned broadcasted shape also has a corresponding dimension having a size equal to ``None``) or raise an exception.
64+
"""
65+
66+
3867
defbroadcast_to(x:array,/,shape:Tuple[int, ...])->array:
3968
"""
4069
Broadcasts an array to a specified shape.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp