moveaxis
将数组的轴移动到新的位置。
其他轴保持其原始顺序不变。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
a
|
SparseArray
|
要重新排序轴的数组。 |
必需 |
source
|
int 或 List[int]
|
要移动轴的原始位置。这些位置必须是唯一的。 |
必需 |
destination
|
int 或 List[int]
|
每个原始轴的目标位置。这些位置也必须是唯一的。 |
必需 |
返回值
类型 | 描述 |
---|---|
SparseArray
|
轴已移动的数组。 |
示例
>>> 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>
源代码位于 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 |
|