Include `alignto` as an operator inside `warp`
Closed this issue · 1 comments
ekshaks commented
Old:
x = np.random.randn(10,50,300)
x = x[None, None, None, :].permute(3, 0, 1, 2)
New:
from tsalib import dim_vars, get_dim_vars, alignto, warp
# B, T, D, C = dim_vars('B(b):10 T(t):50 D(d):300 C(c):4') #one time, in __main__
B, T, D, C = get_dim_vars('b t d c')
x: 'btd' = np.random.randn(B,T,D)
x = alignto((x, 'btd'), 'btdc')
x = warp(x, 'btdc -> cbtd', 'p') #'p' for permute
combine last two lines as:
x = warp(x, 'btd -> btdc -> cbtd', 'ap') #'a' for align