本文整理汇总了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},