Esempio n. 1
0
 def test_add_on_event(self):
     # Signature: name(self, on_event)
     # Add an OnEvent transition which leaves this regime
     #
     # If the on_event object has not had its target regime name set in the
     # constructor, or by calling its ``set_target_regime_name()``, then the
     # target is assumed to be this regime, and will be set appropriately.
     #
     # The source regime for this transition will be set as this regime.
     # from nineml.abstraction.component.dynamics import Regime
     r = Regime(name='R1')
     self.assertEquals(unique_by_id(r.on_events), [])
     r.add(OnEvent('sp'))
     self.assertEquals(len(unique_by_id(r.on_events)), 1)
     self.assertEquals(len(unique_by_id(r.on_conditions)), 0)
     self.assertEquals(len(unique_by_id(r.transitions)), 1)
Esempio n. 2
0
    def test_add_on_condition(self):
        # Signature: name(self, on_condition)
        # Add an OnCondition transition which leaves this regime
        #
        # If the on_condition object has not had its target regime name set in
        # the constructor, or by calling its ``set_target_regime_name()``, then
        # the target is assumed to be this regime, and will be set
        # appropriately.
        #
        # The source regime for this transition will be set as this regime.

        r = Regime(name='R1')
        self.assertEquals(unique_by_id(r.on_conditions), [])
        r.add(OnCondition('sp1>0'))
        self.assertEquals(len(unique_by_id(r.on_conditions)), 1)
        self.assertEquals(len(unique_by_id(r.on_events)), 0)
        self.assertEquals(len(unique_by_id(r.transitions)), 1)