MCPcopy
hub / github.com/dask/dask / transposelist

Function transposelist

dask/array/core.py:5484–5507  ·  view source on GitHub ↗

Permute axes of nested list >>> transposelist([[1,1,1],[1,1,1]], [2,1]) [[[1, 1], [1, 1], [1, 1]]] >>> transposelist([[1,1,1],[1,1,1]], [2,1], extradims=1) [[[[1], [1]], [[1], [1]], [[1], [1]]]]

(arrays, axes, extradims=0)

Source from the content-addressed store, hash-verified

5482
5483
5484def transposelist(arrays, axes, extradims=0):
5485 """Permute axes of nested list
5486
5487 >>> transposelist([[1,1,1],[1,1,1]], [2,1])
5488 [[[1, 1], [1, 1], [1, 1]]]
5489
5490 >>> transposelist([[1,1,1],[1,1,1]], [2,1], extradims=1)
5491 [[[[1], [1]], [[1], [1]], [[1], [1]]]]
5492 """
5493 if len(axes) != ndimlist(arrays):
5494 raise ValueError("Length of axes should equal depth of nested arrays")
5495 if extradims < 0:
5496 raise ValueError("`newdims` should be positive")
5497 if len(axes) > len(set(axes)):
5498 raise ValueError("`axes` should be unique")
5499
5500 ndim = max(axes) + 1
5501 shape = shapelist(arrays)
5502 newshape = [
5503 shape[axes.index(i)] if i in axes else 1 for i in range(ndim + extradims)
5504 ]
5505
5506 result = list(core.flatten(arrays))
5507 return reshapelist(newshape, result)
5508
5509
5510def stack(seq, axis=0, allow_unknown_chunksizes=False):

Callers 1

concatenate_axesFunction · 0.85

Calls 7

ndimlistFunction · 0.90
maxFunction · 0.90
reshapelistFunction · 0.90
setClass · 0.85
shapelistFunction · 0.85
flattenMethod · 0.80
indexMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…