T3Variations.stack ================== .. py:method:: t3toolbox.frame_variations_format.T3Variations.stack(xx) :staticmethod: .. code-block:: python def stack( xx, # Array-like tree of T3Variations ): Stack array-like tree of T3Variations into a single T3Variation. .. rubric:: Examples >>> import numpy as np >>> import t3toolbox.frame_variations_format as bvf >>> import t3toolbox.corewise as cw >>> np.random.seed(0) >>> rnd = lambda x: np.random.randn(*x) >>> ss = (2, 3) # stack >>> NN, nnU, nnD, rrL, rrR = (10, 11, 12), (8, 7, 8), (6, 7, 8), (2, 3, 4, 3), (5, 4, 6, 1) >>> tucker_variations = tuple(rnd(ss+(n, N)) for n, N in zip(nnD, NN)) >>> tt_variations = tuple(rnd(ss+(rL, n, rR)) for rL, n, rR in zip(rrL[:-1], nnU, rrR[1:])) >>> V = bvf.T3Variations(tucker_variations, tt_variations) >>> V2 = bvf.T3Variations.stack(V.unstack()) # stack is the inverse of unstack >>> print(np.allclose(cw.corewise_norm(cw.corewise_sub(V.data, V2.data)), 0.0)) True