Skip to content

Commit b823223

Browse files
authored
Merge pull request #656 from kgryte/moveaxis
PR-URL: #656
2 parents 9dbdec0 + 8149b33 commit b823223

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

spec/draft/API_specification/manipulation_functions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Objects in API
2323
concat
2424
expand_dims
2525
flip
26+
moveaxis
2627
permute_dims
2728
reshape
2829
roll

src/array_api_stubs/_draft/manipulation_functions.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"concat",
55
"expand_dims",
66
"flip",
7+
"moveaxis",
78
"permute_dims",
89
"reshape",
910
"roll",
@@ -114,6 +115,31 @@ def flip(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None) ->
114115
"""
115116

116117

118+
def moveaxis(
119+
x: array,
120+
source: Union[int, Tuple[int, ...]],
121+
destination: Union[int, Tuple[int, ...]],
122+
/,
123+
) -> array:
124+
"""
125+
Moves array axes (dimensions) to new positions, while leaving other axes in their original positions.
126+
127+
Parameters
128+
----------
129+
x: array
130+
input array.
131+
source: Union[int, Tuple[int, ...]]
132+
Axes to move. Provided axes must be unique. If ``x`` has rank (i.e, number of dimensions) ``N``, a valid axis must reside on the half-open interval ``[-N, N)``.
133+
destination: Union[int, Tuple[int, ...]]
134+
indices defining the desired positions for each respective ``source`` axis index. Provided indices must be unique. If ``x`` has rank (i.e, number of dimensions) ``N``, a valid axis must reside on the half-open interval ``[-N, N)``.
135+
136+
Returns
137+
-------
138+
out: array
139+
an array containing reordered axes. The returned array must have the same data type as ``x``.
140+
"""
141+
142+
117143
def permute_dims(x: array, /, axes: Tuple[int, ...]) -> array:
118144
"""
119145
Permutes the axes (dimensions) of an array ``x``.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy