bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / sparse / _construct / permute_dims
function
scipy.sparse._construct:permute_dims
source: build-install/usr/lib/python3.14/site-packages/scipy/sparse/_construct.py:130
Signature
def permute_dims(A, axes = None, copy = False)Summary
Permute the axes of the sparse array A to the order axes.
Parameters
A: sparse arrayInput array.
axes: tuple or list of ints, optionalIf specified, it must be a tuple or list which contains a permutation of
[0, 1, ..., N-1]whereNisA.ndim. The ith axis of the returned array will correspond to the axis numberedaxes[i]of the input. If not specified, defaults torange(A.ndim)[::-1], which reverses the order of the axes.copy: bool, optional (default: False)Whether to return the permutation as a copy. If False, an in-place permutation is provided if possible depending on format.
Returns
out: sparse array in COO formatA copy of
Awith permuted axes.
Raises
: ValueErrorIf provided a non-integer or out of range
[-N, N-1]axis, whereNisA.ndim.
Examples
from scipy.sparse import coo_array, permute_dims A = coo_array([[[1, 2, 3], [2, 0, 0]]]) A.shape permute_dims(A, axes=(1, 2, 0)).shape✓
(2, 3, 1)
Aliases
scipy.sparse.permute_dims