finam.CallbackOutput#
- class finam.CallbackOutput(callback, name, info=None, **info_kwargs)[source]#
Bases:
Output
Output implementation calling a callback when pulled.
Use for components without time step.
- Parameters:
callback (callable) – A callback
callback(data, time)
, returning the transformed data.- Attributes:
has_targets
Flag if this output instance has any targets.
info
Info: The input’s data info.
is_static
Whether the output is static
logger
Logger for this component.
logger_name
Logger name derived from base logger name and class name.
memory_limit
The memory limit for this slot
memory_location
The memory-mapping location for this slot
name
Input name.
needs_pull
bool: if the output needs pull.
needs_push
bool: if the output needs push.
targets
Get target inputs and adapters for this output.
time
The output’s time of the latest available data
uses_base_logger_name
Whether this class has a
base_logger_name
attribute.
Methods
add_target
(target)Add a target input or adapter for this output.
chain
(other)Chain outputs and adapters.
finalize
()Finalize the output
get_data
(time, target)Get the output's data-set for the given time.
get_info
(info)Exchange and get the output's data info.
has_info
()Returns if the output has a data info.
notify_targets
(time)Notify all targets by calling their
source_updated(time)
method.pinged
(source)Called when receiving a ping from a downstream input.
push_data
(data, time)Push data into the output.
push_info
(info)Push data info into the output.
- push_data(data, time)[source]#
Push data into the output.
Should notify targets, and can handle the provided date.
- Parameters:
data (array_like) – Data set to push.
time (
datetime
) – Simulation time of the data set.
- get_data(time, target)[source]#
Get the output’s data-set for the given time.
- Parameters:
- Returns:
Data-set for the requested time.
- Return type:
- Raises:
FinamNoDataError – Raises the error if no data is available
- add_target(target)#
Add a target input or adapter for this output.
- Parameters:
target (
IInput
) – The target to add.
- chain(other)#
Chain outputs and adapters.
- get_info(info)#
Exchange and get the output’s data info.
For internal use. To get the info in a component, use property
info
.- Parameters:
info (
Info
) – Requested data info- Returns:
Delivered data info
- Return type:
- Raises:
FinamNoDataError – Raises the error if no info is available
- has_info()#
Returns if the output has a data info.
The info is not required to be validly exchanged.
- property has_targets#
Flag if this output instance has any targets.
- property is_static#
Whether the output is static
- property logger#
Logger for this component.
- property logger_name#
Logger name derived from base logger name and class name.
- property memory_limit#
The memory limit for this slot
- property memory_location#
The memory-mapping location for this slot
- property name#
Input name.
- notify_targets(time)#
Notify all targets by calling their
source_updated(time)
method.- Parameters:
time (
datetime
) – Simulation time of the simulation.
- pinged(source)#
Called when receiving a ping from a downstream input.
- property targets#
Get target inputs and adapters for this output.
- Returns:
List of targets.
- Return type:
- property time#
The output’s time of the latest available data
- property uses_base_logger_name#
Whether this class has a
base_logger_name
attribute. True.