types
Data types and protocols for the coding experiments library.
This module defines the core data structures, type aliases, and protocols used throughout the library for representing messages, transmission events, logs, and experimental configurations.
- class codinglab.types.Symbol
Generic type variable representing any symbol type.
alias of TypeVar(‘Symbol’)
- class codinglab.types.SourceChar
Type variable for source alphabet symbols (input to encoder).
alias of TypeVar(‘SourceChar’)
- class codinglab.types.ChannelChar
Type variable for channel alphabet symbols (output from encoder).
alias of TypeVar(‘ChannelChar’)
- class codinglab.types.Message(id, data)[source]
-
A message containing a sequence of symbols.
This class represents a message as an immutable sequence of symbols with a unique identifier for tracking purposes.
- class codinglab.types.TransmissionEvent(*values)[source]
-
Events that occur during message transmission.
These events are logged throughout the transmission pipeline for monitoring, debugging, and analysis purposes.
- SOURCE_GENERATED = 'source_generated'
Event when a source message is generated.
- ENCODED = 'encoded'
Event when a message is encoded.
- TRANSMITTED = 'transmitted'
Event when a message is transmitted through a channel.
- RECEIVED = 'received'
Event when a message is received from a channel.
- DECODED = 'decoded'
Event when a message is decoded.
- VALIDATED = 'validated'
Event when a message is validated.
- ERROR = 'error'
Event when an error occurs during transmission.
- class codinglab.types.TransmissionLog(timestamp, event, message, data)[source]
-
Log entry for a transmission event.
Contains detailed information about a specific event in the transmission pipeline, including timing, message data, and additional context.
- Parameters:
- __init__(timestamp, event, message, data)
- event: TransmissionEvent
Type of transmission event.
- class codinglab.types.TransmissionLogger(*args, **kwargs)[source]
Bases:
ProtocolProtocol for logging transmission events.
Implementations of this protocol are responsible for handling log entries generated during message transmission, which can be used for monitoring, debugging, or analytics.
- __init__(*args, **kwargs)
- log(log_entry)[source]
Log a transmission event.
- Parameters:
log_entry (
TransmissionLog) – The transmission log entry to record- Return type: