本文整理匯總了Python中machinist.TransitionTable.addTerminalState方法的典型用法代碼示例。如果您正苦於以下問題:Python TransitionTable.addTerminalState方法的具體用法?Python TransitionTable.addTerminalState怎麽用?Python TransitionTable.addTerminalState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類machinist.TransitionTable
的用法示例。
在下文中一共展示了TransitionTable.addTerminalState方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_addTerminalState
# 需要導入模塊: from machinist import TransitionTable [as 別名]
# 或者: from machinist.TransitionTable import addTerminalState [as 別名]
def test_addTerminalState(self):
"""
L{TransitionTable.addTerminalState} returns a L{TransitionTable} that
includes the given state in its table with no transitions defined.
"""
table = TransitionTable()
more = table.addTerminalState("foo")
self.assertEqual({"foo": {}}, more.table)
示例2: test_nextStateNotMissingIfInitial
# 需要導入模塊: from machinist import TransitionTable [as 別名]
# 或者: from machinist.TransitionTable import addTerminalState [as 別名]
def test_nextStateNotMissingIfInitial(self):
"""
L{MissingTransitionNextState} is not raised if a value defined by
C{state} appears nowhere in C{transitions} as a next state but is given
as C{initial}.
"""
transitions = TransitionTable()
transitions = transitions.addTransition(
MoreState.amber, Input.apple, [Output.aardvark], MoreState.amber)
transitions = transitions.addTerminalState(MoreState.blue)
constructFiniteStateMachine(
Input, Output, MoreState, transitions,
MoreState.blue, [], {}, NULL_WORLD)
示例3: test_missingTransitionNextState
# 需要導入模塊: from machinist import TransitionTable [as 別名]
# 或者: from machinist.TransitionTable import addTerminalState [as 別名]
def test_missingTransitionNextState(self):
"""
L{MissingTransitionNextState} is raised if any of the values defined by
C{state} appears nowhere in C{transitions} as a next state.
"""
transitions = TransitionTable()
transitions = transitions.addTransition(
MoreState.amber, Input.apple, [Output.aardvark], MoreState.amber)
transitions = transitions.addTerminalState(MoreState.blue)
exc = self.assertRaises(
MissingTransitionNextState,
constructFiniteStateMachine,
Input, Output, MoreState, transitions,
MoreState.amber, [], {}, NULL_WORLD)
self.assertEqual(({MoreState.blue},), exc.args)
示例4: IFood
# 需要導入模塊: from machinist import TransitionTable [as 別名]
# 或者: from machinist.TransitionTable import addTerminalState [as 別名]
class IFood(Interface):
radius = Attribute("The radius of the food (all food is spherical)")
@implementer(IFood)
class Gravenstein(trivialInput(Input.apple)):
# Conveniently, apples are approximately spherical.
radius = 3
TRANSITIONS = TransitionTable()
TRANSITIONS = TRANSITIONS.addTransition(
MoreState.amber, Input.apple, [Output.aardvark], MoreState.blue)
TRANSITIONS = TRANSITIONS.addTerminalState(MoreState.blue)
class FiniteStateMachineTests(TestCase):
"""
Tests for the L{IFiniteStateMachine} provider returned by
L{constructFiniteStateMachine}.
"""
def setUp(self):
self.animals = []
self.initial = MoreState.amber
self.world = AnimalWorld(self.animals)
self.fsm = constructFiniteStateMachine(
Input, Output, MoreState, TRANSITIONS, self.initial,
[Gravenstein], {Output.aardvark: IFood},