Skip to content

Commit

Permalink
Refact: StreamTask, OATask - order of processing/adaption on new/obso…
Browse files Browse the repository at this point in the history
…lete instances #988
  • Loading branch information
detlefarend committed May 22, 2024
1 parent 7405d78 commit 6567ee2
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 23 deletions.
15 changes: 7 additions & 8 deletions src/mlpro/bf/streams/tasks/deriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
## -- 2023-02-02 0.0.0 SY Creation
## -- 2023-02-05 1.0.0 SY First version release
## -- 2024-05-10 1.0.1 DA/SY Bugfix in Deriver.__init__()
## -- 2024-05-22 1.1.0 DA Refactoring
## -------------------------------------------------------------------------------------------------

"""
Ver. 1.0.1 (2024-05-10)
Ver. 1.1.0 (2024-05-22)
This module provides a stream task class Deriver to derive the data of instances.
"""
Expand All @@ -21,7 +22,7 @@
from mlpro.bf.various import Log
from mlpro.bf.mt import Task
from mlpro.bf.math import Set, Element
from mlpro.bf.streams import Instance, StreamTask, Feature, Label
from mlpro.bf.streams import Instance, InstDict, StreamTask, Feature, Label
from mlpro.bf.physics import TransferFunction
import numpy as np

Expand Down Expand Up @@ -61,8 +62,8 @@ class Deriver(StreamTask):
Further optional named parameters.
"""

C_NAME = 'Deriver'
C_PLOT_STANDALONE = True
C_NAME = 'Deriver'
C_PLOT_STANDALONE = True

## -------------------------------------------------------------------------------------------------
def __init__( self,
Expand Down Expand Up @@ -174,13 +175,11 @@ def _derive_data(self, p_inst:Instance):


## -------------------------------------------------------------------------------------------------
def _run(self, p_inst_new: set, p_inst_del: set):
def _run(self, p_inst : InstDict ):

for inst in p_inst_new:
for (inst_type,inst) in sorted(p_inst.values()):
self._derive_data(p_inst=inst)

for inst in p_inst_del:
self._derive_data(p_inst=inst)



Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - A Synoptic Framework for Standardized Machine Learning Tasks
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.bf.examples
## -- Module : howto_bf_streams_001_tasks_workflows_and_stream_scenarios.py
## -------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion test/howtos/bf/howto_bf_streams_110_stream_task_window.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - A Synoptic Framework for Standardized Machine Learning Tasks
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.bf.examples
## -- Module : howto_bf_streams_110_stream_task_window.py
## -------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - A Synoptic Framework for Standardized Machine Learning Tasks
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.bf.examples
## -- Module : howto_bf_streams_111_stream_task_rearranger_2d.py
## -------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - A Synoptic Framework for Standardized Machine Learning Tasks
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.bf.examples
## -- Module : howto_bf_streams_112_stream_task_rearranger_3d.py
## -------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - A Synoptic Framework for Standardized Machine Learning Tasks
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.bf.examples
## -- Module : howto_bf_streams_113_stream_task_rearranger_nd.py
## -------------------------------------------------------------------------------------------------
Expand Down
12 changes: 7 additions & 5 deletions test/howtos/bf/howto_bf_streams_114_stream_task_deriver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - A Synoptic Framework for Standardized Machine Learning Tasks
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.bf.examples
## -- Module : howto_bf_streams_114_stream_task_deriver.py
## -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -50,7 +50,7 @@ class MyTask (StreamTask):
C_NAME = 'Custom'

## -------------------------------------------------------------------------------------------------
def _run(self, p_inst_new: list, p_inst_del: list):
def _run(self, p_inst: InstDict):
pass


Expand Down Expand Up @@ -82,7 +82,7 @@ def _setup(self, p_mode, p_visualize: bool, p_logging):
features = stream.get_feature_space().get_dims()
features_new = [ ( 'F', features[0:1] ) ]

task_rearranger = Rearranger( p_name='t1',
task_rearranger = Rearranger( p_name='T1 - Rearranger',
p_range_max=Task.C_RANGE_THREAD,
p_visualize=p_visualize,
p_logging=p_logging,
Expand All @@ -94,7 +94,7 @@ def _setup(self, p_mode, p_visualize: bool, p_logging):
features = task_rearranger._feature_space.get_dims()
derived_feature = features[0]

task_deriver_1 = Deriver( p_name='t2',
task_deriver_1 = Deriver( p_name='T2 - Deriver 1',
p_range_max=Task.C_RANGE_THREAD,
p_visualize=p_visualize,
p_logging=p_logging,
Expand All @@ -110,7 +110,7 @@ def _setup(self, p_mode, p_visualize: bool, p_logging):
features = task_deriver_1._feature_space.get_dims()
derived_feature = features[0]

task_deriver_2 = Deriver( p_name='t3',
task_deriver_2 = Deriver( p_name='T3 - Deriver 2',
p_range_max=Task.C_RANGE_THREAD,
p_visualize=p_visualize,
p_logging=p_logging,
Expand Down Expand Up @@ -155,6 +155,8 @@ def _setup(self, p_mode, p_visualize: bool, p_logging):
if __name__ == '__main__':
myscenario.init_plot( p_plot_settings=PlotSettings( p_view = PlotSettings.C_VIEW_ND,
p_view_autoselect = False,
p_plot_horizon = 50,
p_data_horizon = 100,
p_step_rate = 2 ) )
input('Press ENTER to start stream processing...')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - A Synoptic Framework for Standardized Machine Learning Tasks
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.bf.examples
## -- Module : howto_bf_systems_001.py
## -------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - A Synoptic Framework for Standardized Machine Learning Tasks
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.bf.examples
## -- Module : howto_bf_systems_010_systems_controllers_actuators_sensors.py
## -------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - A Synoptic Framework for Standardized Machine Learning Tasks
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.bf.examples
## -- Module : howto_bf_systems_021_multisystem_flipflop.py
## -------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - A Synoptic Framework for Standardized Machine Learning Tasks
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.bf.examples
## -- Module : howto_bf_systems_030_adaptive_double_pendulum_system.py
## -------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## -------------------------------------------------------------------------------------------------
## -- Project : MLPro - A Synoptic Framework for Standardized Machine Learning Tasks
## -- Project : MLPro - The integrative middleware framework for standardized machine learning
## -- Package : mlpro.bf.examples
## -- Module : howto_bf_ui_001_reuse_of_interactive_2d_3d_input_space.py
## -------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 6567ee2

Please sign in to comment.