MCPcopy Create free account
hub / github.com/dask/dask / transposelist

Function transposelist

dask/array/core.py:5479–5502  ·  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

5477
5478
5479def transposelist(arrays, axes, extradims=0):
5480 """Permute axes of nested list
5481
5482 >>> transposelist([[1,1,1],[1,1,1]], [2,1])
5483 [[[1, 1], [1, 1], [1, 1]]]
5484
5485 >>> transposelist([[1,1,1],[1,1,1]], [2,1], extradims=1)
5486 [[[[1], [1]], [[1], [1]], [[1], [1]]]]
5487 """
5488 if len(axes) != ndimlist(arrays):
5489 raise ValueError("Length of axes should equal depth of nested arrays")
5490 if extradims < 0:
5491 raise ValueError("`newdims` should be positive")
5492 if len(axes) > len(set(axes)):
5493 raise ValueError("`axes` should be unique")
5494
5495 ndim = max(axes) + 1
5496 shape = shapelist(arrays)
5497 newshape = [
5498 shape[axes.index(i)] if i in axes else 1 for i in range(ndim + extradims)
5499 ]
5500
5501 result = list(core.flatten(arrays))
5502 return reshapelist(newshape, result)
5503
5504
5505def 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