RandomScale#
- class RandomScale(scale=None, anisotropic=False)[source]#
Bases:
objectScale
coordby a random factor.Draws a uniform scale from
scale– a single shared factor whenanisotropicisFalseor three independent per-axis factors whenTrue– and multipliescoordin place. The same factor is applied to v3vertexmetadata andaux_position_keys; direction keys are left unchanged. Requirescoord; a no-op ifcoordis absent. Registered asRandomScale– use this string as thetypein atransform=[...]config list.- Parameters:
scale (Sequence[float], optional) –
[low, high]range for the uniform scale factor.Nonemeans[0.95, 1.05]. Defaults toNone.anisotropic (bool) – if
True, sample an independent factor per axis; otherwise use one shared factor. Defaults toFalse.
Note
Direction keys are intentionally not scaled: isotropic scaling preserves orientation, and anisotropic scaling of unit-direction targets is unsupported.
Example
>>> import numpy as np >>> from pimm.datasets.transform import RandomScale >>> data = {"coord": np.array([[1., 2., 3.], [4., 5., 6.]], dtype="f4")} >>> # degenerate range [2, 2] -> a fixed 2x scale, so the effect is visible >>> out = RandomScale(scale=[2.0, 2.0])(data) >>> out["coord"] array([[ 2., 4., 6.], [ 8., 10., 12.]], dtype=float32)