moveaxis
Move axes of an array to new positions.
Other axes remain in their original order.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a
|
SparseArray
|
The array whose axes should be reordered. |
required |
source
|
int or List[int]
|
Original positions of the axes to move. These must be unique. |
required |
destination
|
int or List[int]
|
Destination positions for each of the original axes. These must also be unique. |
required |
Returns:
Type | Description |
---|---|
SparseArray
|
Array with moved axes. |
Examples:
>>> import numpy as np
>>> import sparse
>>> x = sparse.COO.from_numpy(np.ones((2, 3, 4, 5)))
>>> sparse.moveaxis(x, (0, 1), (2, 3))
<COO: shape=(4, 5, 2, 3), dtype=float64, nnz=120, fill_value=0.0>
Source code in sparse/numba_backend/_common.py
1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 |
|