RandomScale#

class RandomScale(scale=None, anisotropic=False)[source]#

Bases: object

Scale coord by a random factor.

Draws a uniform scale from scale – a single shared factor when anisotropic is False or three independent per-axis factors when True – and multiplies coord in place. The same factor is applied to v3 vertex metadata and aux_position_keys; direction keys are left unchanged. Requires coord; a no-op if coord is absent. Registered as RandomScale – use this string as the type in a transform=[...] config list.

Parameters:
  • scale (Sequence[float], optional) – [low, high] range for the uniform scale factor. None means [0.95, 1.05]. Defaults to None.

  • anisotropic (bool) – if True, sample an independent factor per axis; otherwise use one shared factor. Defaults to False.

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)