T3Frame.stack#
- static t3toolbox.frame_variations_format.T3Frame.stack(xx)#
def stack( xx, # Array-like tree of T3Frame ):
Stack array-like tree of T3Frame into a single T3Frame.
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 C >>> up_tucker_cores = (rnd(ss+(10, 14)), rnd(ss+(11, 15)), rnd(ss+(12, 16))) >>> down_tt_cores = (rnd(ss+(1, 9, 4)), rnd(ss+(2, 8, 5)), rnd(ss+(3, 7, 1))) >>> left_tt_cores = (rnd(ss+(1, 10, 2)), rnd(ss+(2, 11, 3)), rnd(ss+(3, 12, 5))) >>> right_tt_cores = (rnd(ss+(2, 10, 4)), rnd(ss+(4, 11, 5)), rnd(ss+(5, 12, 1))) >>> x = bvf.T3Frame(up_tucker_cores, down_tt_cores, left_tt_cores, right_tt_cores) >>> x2 = bvf.T3Frame.stack(x.unstack()) # stack is the inverse of unstack >>> print(np.allclose(cw.corewise_norm(cw.corewise_sub(x.data, x2.data)), 0.0)) True