def do_to_assignments_and_events(doList): if not doList: return [], [] # 'doList' is a list of strings, OutputEvents, and StateAssignments. do_type_list = (OutputEvent, basestring, StateAssignment) do_types = nineml.utility.filter_discrete_types(doList, do_type_list) # Convert strings to StateAssignments: sa_from_strs = [StrToExpr.state_assignment(s) for s in do_types[basestring]] return do_types[StateAssignment] + sa_from_strs, do_types[OutputEvent]
def __init__(self, state_assignments=None, event_outputs=None, target_regime_name=None): """Abstract class representing a transition from one |Regime| to another. |Transition| objects are not created directly, but via the subclasses |OnEvent| and |OnCondition|. :param state_assignments: A list of the state-assignments performed when this transition occurs. Objects in this list are either `string` (e.g A = A+13) or |StateAssignment| objects. :param event_outputs: A list of |OutputEvent| objects emitted when this transition occurs. :param target_regime_name: The name of the regime to go into after this transition. ``None`` implies staying in the same regime. This has to be specified as a string, not the object, because in general the |Regime| object is not yet constructed. This is automatically resolved by the |ComponentClass| in ``_ResolveTransitionRegimeNames()`` during construction. .. todo:: For more information about what happens at a regime transition, see here: XXXXXXX """ if target_regime_name: assert isinstance(target_regime_name, basestring) # Load state-assignment objects as strings or StateAssignment objects from nineml.utility import filter_discrete_types state_assignments = state_assignments or [] sa_types = (basestring, StateAssignment) sa_type_dict = filter_discrete_types(state_assignments, sa_types) sa_from_str = [StrToExpr.state_assignment(o) for o in sa_type_dict[basestring]] self._state_assignments = sa_type_dict[StateAssignment] + sa_from_str self._event_outputs = event_outputs or [] self._target_regime_name = target_regime_name self._source_regime_name = None # Set later, once attached to a regime: self._target_regime = None self._source_regime = None