torchsig.transforms.impairments.Impairments

class torchsig.transforms.impairments.Impairments(level: int, **kwargs)[source]

Bases: Transform

Applies signal and dataset transformations at specific impairment levels.

This class applies a set of signal and dataset transforms based on a given impairment level. The impairment level must be between 0 and 2, where each level corresponds to different sets of transformations for signals and datasets.

  • Level 0: Perfect (no impairments)

  • Level 1: Cabled environment (transmit impairments only)

  • Level 2: Wireless environment (transmit impairments + channel models)

Parameters:
  • level – The impairment level (must be between 0 and 2).

  • **kwargs – Additional keyword arguments passed to the parent class Transform.

Raises:

ValueError – If the provided impairment level is outside the valid range (0, 1, 2).

level

The specified impairment level.

signal_transforms

The composed signal transformations corresponding to the given impairment level.

dataset_transforms

The composed dataset transformations corresponding to the given impairment level.

Methods

add_parent

Add parent Seedable object and set up RNGs accordingly.

get_dataset_transforms

Get the dataset transforms for this impairment level.

get_distribution

Create distribution function with proper seeding.

get_second_seed

Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds.

get_signal_transforms

Get the signal transforms for this impairment level.

seed

Seed number generators with given seed.

setup_rngs

Initialize torch and numpy number generators, and update its children.

update_from_parent

Update numpy and torch number generators with parent seed.

__init__(level: int, **kwargs)[source]

Initialize the Impairments class.

Parameters:
  • level – The impairment level (must be between 0 and 2).

  • **kwargs – Additional keyword arguments passed to the parent class Transform.

get_signal_transforms() list[Transform][source]

Get the signal transforms for this impairment level.

Returns:

List of signal transforms configured for the current impairment level.

get_dataset_transforms() list[Transform][source]

Get the dataset transforms for this impairment level.

Returns:

List of dataset transforms configured for the current impairment level.

__call__(signal)

Validate signal, performs transform, update bookeeping.

Parameters:

signal – Signal to be transformed.

Raises:

NotImplementedError – Inherited classes must override this method.

Returns:

Transformed Signal.

__repr__() str

Transform string representation.

Should be able to recreate class from this string.

Returns:

Transform representation.

__str__() str

String representation of the transform.

Returns:

String representation of the transform.

add_parent(parent: Seedable, register: bool = True) None

Add parent Seedable object and set up RNGs accordingly.

Parameters:
  • parent – Parent Seedable object to add.

  • register – If True (default), add self to parent.children so that future seed propagation reaches this object. Pass False for transient objects (e.g. per-sample Signal instances) that only need the parent link for metadata/RNG access during their lifetime but must not accumulate in the parent’s child list, which would otherwise cause unbounded memory growth.

get_distribution(params: list | tuple | float, scaling: str = 'linear') Distribution

Create distribution function with proper seeding.

Parameters:
  • params – Parameters for distribution.

  • scaling – Scaling param for distribution. Defaults to ‘linear’.

Returns:

Distribution function, seeded.

Return type:

Distribution

get_second_seed(seed: int) int

Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds.

Parameters:

seed – Seed to use.

Returns:

New seed.

seed(seed: int) None

Seed number generators with given seed.

Parameters:

seed – Seed to use.

setup_rngs() None

Initialize torch and numpy number generators, and update its children.

update_from_parent() None

Update numpy and torch number generators with parent seed.