ezmsg.sigproc.math.difference#
Take the difference between 2 signals or between a signal and a constant value.
Note
ConstDifferenceTransformer supports the Array API standard,
enabling use with NumPy, CuPy, PyTorch, and other compatible array libraries.
DifferenceProcessor (two-input difference) currently requires NumPy arrays.
Functions
- const_difference(value=0.0, subtrahend=True)[source]#
result = (in_data - value) if subtrahend else (value - in_data) https://en.wikipedia.org/wiki/Template:Arithmetic_operations
- Parameters:
- Return type:
Returns:
ConstDifferenceTransformer.
Classes
- class ConstDifference(*args, settings=None, **kwargs)[source]#
Bases:
BaseTransformerUnit[ConstDifferenceSettings,AxisArray,AxisArray,ConstDifferenceTransformer]- Parameters:
settings (Settings | None)
- SETTINGS#
alias of
ConstDifferenceSettings
- class ConstDifferenceSettings(value: float = 0.0, subtrahend: bool = True)[source]#
Bases:
Settings
- class ConstDifferenceTransformer(*args, settings=None, **kwargs)[source]#
Bases:
BaseTransformer[ConstDifferenceSettings,AxisArray,AxisArray]- Parameters:
settings (SettingsType)
- class Difference(*args, settings=None, **kwargs)[source]#
Bases:
UnitSubtract two signals (A - B).
Assumes compatible/similar axes/dimensions and aligned time spans. Messages are paired by arrival order (oldest from each queue).
OUTPUT = INPUT_SIGNAL_A - INPUT_SIGNAL_B
- Parameters:
settings (Settings | None)
- INPUT_SIGNAL_A = InputStream:unlocated[AxisArray]()#
- INPUT_SIGNAL_B = InputStream:unlocated[AxisArray]()#
- OUTPUT_SIGNAL = OutputStream:unlocated[AxisArray](self.num_buffers=32, self.force_tcp=False)#
- async initialize()[source]#
Runs when the Unit is instantiated.
This is called from within the same process this unit will live in. This lifecycle hook can be overridden. It can be run as async functions by simply adding the async keyword when overriding.
This method is where you should initialize your unit’s state and prepare for message processing.
- Return type:
None
- class DifferenceProcessor[source]#
Bases:
objectProcessor that subtracts two AxisArray signals (A - B).
This processor maintains separate queues for two input streams and subtracts corresponding messages element-wise. It assumes both inputs have compatible shapes and aligned time spans.
- property state: DifferenceState#