You are viewing an older version (1.17.1).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 1.17.1 / scipy / sparse / _construct / swapaxes

function

scipy.sparse._construct:swapaxes

source: /scipy/sparse/_construct.py:85

Signature

def swapaxes(A, axis1, axis2)

Summary

Interchange two axes of an array.

Parameters

A : sparse array
axis1 : int

First axis.

axis2 : int

Second axis.

Returns

a_swapped : sparse array in COO format

A copy of the input array with the two identified axes swapped.

Raises

: ValueError

If provided a non-integer or out of range [-N, N-1] axis, where N is A.ndim.

Examples

from scipy.sparse import coo_array, swapaxes
A = coo_array([[[1, 2, 3], [2, 0, 0]]])
A.shape
swapaxes(A, 1, 2).shape
✓

Aliases

  • scipy.sparse.swapaxes