Skip to content

Commit

Permalink
projecting initial state
Browse files Browse the repository at this point in the history
  • Loading branch information
prismofeverything committed Jan 11, 2024
1 parent 8f8a2b2 commit ba15606
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
6 changes: 6 additions & 0 deletions process_bigraph/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ def schema(self):
'level': 'float'}}


def initial_state(self):
return {
'inputs': {
'level': 11.0}}


def update(self, state, interval):
return {
'level': state['level'] * self.config['rate']}
Expand Down
20 changes: 16 additions & 4 deletions process_bigraph/type_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
=============
"""

from bigraph_schema import Edge, TypeSystem, get_path, establish_path, set_path
from bigraph_schema import Edge, TypeSystem, get_path, establish_path, set_path, deep_merge
from process_bigraph.registry import protocol_registry


Expand Down Expand Up @@ -290,12 +290,24 @@ def initialize_edge_state(self, schema, path, edge):
output_ports = get_path(schema, path + ('_outputs',))
ports = {'inputs': input_ports, 'outputs': output_ports}

projected_state = self.project_edge(
input_state = self.project_edge(
ports,
edge,
path[:-1],
initial_state)
return projected_state
initial_state,
ports_key='input')

output_state = self.project_edge(
ports,
edge,
path[:-1],
initial_state,
ports_key='output')

state = deep_merge(input_state, output_state)

return state


def dehydrate(self, schema):
return {}
Expand Down

0 comments on commit ba15606

Please sign in to comment.