Skip to content

Commit

Permalink
Fix transducible inheritance in Cell-DEVS messages
Browse files Browse the repository at this point in the history
  • Loading branch information
romancardenas committed Jun 25, 2024
1 parent c6c38ae commit 7ad49b9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions xdevs/celldevs/inout.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ def transducer_map(cls) -> dict[str, tuple[Type[T], Callable[[Any], T]]]:
if issubclass(cls.state_t, Transducible):
res = {'cell_id': (str, lambda x: x.cell_id)}
for field, (t, l) in cls.state_t.transducer_map().items():
res[field] = (t, lambda x: l(x.cell_state))
# f is a fake lambda input parameter to capture the current value of l
# We need this to avoid the late binding problem in lambda functions
res[field] = (t, lambda x, f=l: f(x.cell_state))
return res
# return {
# 'cell_id': (str, lambda x: x.cell_id),
# **{field: (t, lambda x: l(x.cell_state)) for field, (t, l) in cls.state_t.transducer_map().items()}
#}
return {
'cell_id': (str, lambda x: x.cell_id),
'cell_state': (str, lambda x: x.cell_state),
Expand Down

0 comments on commit 7ad49b9

Please sign in to comment.