torchsig.signals.builders.constellation.ConstellationSignalGenerator¶
- class torchsig.signals.builders.constellation.ConstellationSignalGenerator(**kwargs: dict[str, str | float | int])[source]¶
Bases:
BaseSignalGeneratorConstellation Signal Generator.
Implements multiple constellation based waveforms (QAM/PSK/ASK/OOK).
Methods
Add parent Seedable object and set up RNGs accordingly.
Creates a deep copy of the SignalGenerator with copied transforms.
Generates a constellation signal based on the configured parameters.
Create distribution function with proper seeding.
Function for modifying and returning a new metadata with all the fields in parent or child, with child overriding parent in conflicts.
Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds.
Lookup a metadata key with enhanced error reporting.
Get all metadata keys.
Seed number generators with given seed.
Sets the class_name to name if there wasn't already a class name set.
Initialize torch and numpy number generators, and update its children.
Update numpy and torch number generators with parent seed.
Validates that all required metadata fields are present.
- __init__(**kwargs: dict[str, str | float | int]) None[source]¶
Initializes Constellation Signal Generator.
- Parameters:
**kwargs – Metadata parameters including: - constellation_name: Name of the constellation (e.g., ‘qpsk’) - sample_rate: Sampling rate (Hz) - bandwidth_min: Minimum bandwidth (Hz) - bandwidth_max: Maximum bandwidth (Hz) - signal_duration_in_samples_min: Minimum signal duration (samples) - signal_duration_in_samples_max: Maximum signal duration (samples)
- Raises:
ValueError – If required metadata fields are missing or invalid.
- generate() Signal[source]¶
Generates a constellation signal based on the configured parameters.
- Returns:
Generated constellation signal with metadata.
- Return type:
- Raises:
ValueError – If required metadata fields are missing or invalid.
- __call__() Signal¶
Generates a new signal and applies all transforms.
- Returns:
The generated signal after applying all transforms.
- __repr__() str¶
Returns a string representation of the SignalGenerator.
- Returns:
A string representation showing the class name, metadata, and transforms.
- 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.
- copy() BaseSignalGenerator¶
Creates a deep copy of the SignalGenerator with copied transforms.
- Returns:
A new instance of the SignalGenerator with copied metadata and transforms.
- 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:
- get_full_metadata() dict[str, Any]¶
Function for modifying and returning a new metadata with all the fields in parent or child, with child overriding parent in conflicts.
- Returns:
Dictionary containing all metadata from parent and child, with child values overriding parent values in case of conflicts.
Example
>>> parent = HierarchicalMetadataObject(metadata={"field_1": 4, "field_2": 5}) >>> child = HierarchicalMetadataObject(parent=parent, metadata={"field_2": 6}) >>> child.get_full_metadata() {'field_1': 4, 'field_2': 6}
- 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.
- key_lookup(key: str) Any¶
Lookup a metadata key with enhanced error reporting.
- Parameters:
key – The metadata key to lookup.
- Returns:
The value associated with the key.
- Raises:
MetadataAttributeError – If the key is not found in the metadata or parent metadata.
Example
>>> obj = HierarchicalMetadataObject(metadata={"key": "value"}) >>> obj.key_lookup("key") 'value'
- keys() list[str]¶
Get all metadata keys.
- Returns:
List of all metadata keys.
Example
>>> obj = HierarchicalMetadataObject(metadata={"key1": 1, "key2": 2}) >>> list(obj.keys()) ['key1', 'key2']
- set_default_class_name(name: str) None¶
Sets the class_name to name if there wasn’t already a class name set.
- Parameters:
name – The class name to set if no class name exists.
- validate_metadata_fields() None¶
Validates that all required metadata fields are present.
Throws an exception if required_metadata_fields are not filled. Does nothing if required_metadata_fields is not set.
- Raises:
TypeError – If any required metadata field names are not strings.
ValueError – If any required metadata fields are missing.