corewise_stack_scale#
- t3toolbox.corewise.corewise_stack_scale(X, s)#
def corewise_stack_scale( X: NDArrayTree, # tree; each leaf shape = stack_shape + (core dims) s, # per-stack-slice factor, shape = stack_shape (scalar ndim 0 = uniform) ) -> NDArrayTree: # same tree structure as X, each leaf scaled
Scale each leaf by a per-stack-slice factor
s, broadcastingsover each leaf’s trailing (non-stack) axes.shas shape equal to the leading stack shape; each leaf has shapestack_shape + (core dims). A scalars(ndim 0) scales every entry uniformly, matchingcorewise_scale().Examples
>>> import numpy as np >>> import t3toolbox.corewise as cw >>> X = (np.ones((2, 3)), np.ones((2, 4, 5))) # stack=(2,), then core axes >>> out = cw.corewise_stack_scale(X, np.array([10., 100.])) >>> print(out[0][:, 0], out[1][:, 0, 0]) [ 10. 100.] [ 10. 100.]
- Parameters:
X (NDArrayTree)
- Return type: