当前位置: 首页>>代码示例>>Python>>正文


Python Model.post_init方法代码示例

本文整理汇总了Python中model.Model.post_init方法的典型用法代码示例。如果您正苦于以下问题:Python Model.post_init方法的具体用法?Python Model.post_init怎么用?Python Model.post_init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.Model的用法示例。


在下文中一共展示了Model.post_init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post_init

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import post_init [as 别名]
  def post_init(self):
    """
    Now that all modules have been imported and executed their __init__
     do a postprocessing pass
     to process metadata that might be affected by configuration modules
    """
    # Do all of this work here rather than in __init__
    #  so it can include the effects of any pymodel config modules

    # recognize PEP-8 style names (all lowercase) if present
    if hasattr(self.module, 'testsuite'):
      self.module.testSuite = self.module.testsuite
    if hasattr(self.module, 'test_suite'):
      self.module.testSuite = self.module.test_suite

    if hasattr(self.module, 'actions'):
      self.actions = list(self.module.actions) # copy, actions from cmd line
    else:
      self.actions = list(self.actions_in_suite()) # default, copy
    Model.post_init(self) # uses self.actions
    # Revise the test suite to account for excluded, included actions
    self.test_suite = list()
    for run in self.module.testSuite:
       new_run = list() # list not tuple, must mutable
       for action in run:
         if action[0] in self.actions:
           new_run.append(action)
         else:
           break # truncate the run before the excluded action
       self.test_suite.append(new_run)
    # prepare for first run
    self.irun = 0 # index of current test run in test suite
    self.pc = 0 # program counter
开发者ID:SMV818VMS,项目名称:PyModel,代码行数:35,代码来源:TestSuite.py

示例2: post_init

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import post_init [as 别名]
  def post_init(self):
    """
    Now that all modules have been imported and executed their __init__
     do a postprocessing pass
     to process metadata that might be affected by configuration modules
    """
    # Do all of this work here rather than in __init__
    #  so it can include the effects of any pymodel config modules

    # Make copies of collections that may be altered later
    # self.actions is not used in this module outside this __init__
    #  BUT it is used in several places in Model and ProductModelProgram
    # EnabledTransitions below works directly on self.module.graph,
    #  not self.actions
    if not hasattr(self.module, 'actions'):
      self.actions = list(self.actions_in_graph()) # default, make copy
    else:
      self.actions = list(self.module.actions) # copy
    Model.post_init(self) # uses self.actions
    # Construct self.graph like self.module.graph 
    #  BUT also accounts for include, exclude via self.actions
    self.graph = [ (current, (action,args,result), next) 
                   for (current, (action,args,result), next) in
                   self.module.graph if action in self.actions ]
    # prepare for first run
    self.current = self.module.initial # raise exception if module is not FSM
开发者ID:SMV818VMS,项目名称:PyModel,代码行数:28,代码来源:FSM.py

示例3: post_init

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import post_init [as 别名]
  def post_init(self):
    """
    Now that all modules have been imported and executed their __init__
     do a postprocessing pass 
     to process metadata that might be affected by configuration modules
    """
    # Do all of this work here rather than in __init__
    #  so it can include the effects of any pymodel config modules

    # recognize PEP-8 style names (all lowercase) if present
    if hasattr(self.module, 'accepting'):
      self.module.Accepting = self.module.accepting
    if hasattr(self.module, 'statefilter'):
      self.module.StateFilter = self.module.statefilter
    if hasattr(self.module, 'state_filter'):
      self.module.StateFilter = self.module.state_filter
    if hasattr(self.module, 'stateinvariant'):
      self.module.StateInvariant = self.module.stateinvariant
    if hasattr(self.module, 'state_invariant'):
      self.module.StateInvariant = self.module.state_invariant
    if hasattr(self.module, 'reset'):
      self.module.Reset = self.module.reset

    # assign defaults to optional attributes
    # cleanup and observables are handled in Models base class
    if not hasattr(self.module, 'enablers'):
      self.module.enablers = dict() # all actions always enabled
    if not hasattr(self.module, 'domains'):
      self.module.domains = dict() # empty domains
    if not hasattr(self.module, 'combinations'):
      self.module.combinations = dict() # 'all', Cartesian product
    if not hasattr(self.module, 'Accepting'):
      self.module.Accepting = self.TrueDefault
    if not hasattr(self.module, 'StateFilter'):
      self.module.StateFilter = self.TrueDefault
    if not hasattr(self.module, 'StateInvariant'):
      self.module.StateInvariant = self.TrueDefault

    # Make copies of collections that may be altered by post_init
    self.actions =  list(self.module.actions)
    Model.post_init(self) # uses self.actions
开发者ID:SMV818VMS,项目名称:PyModel,代码行数:43,代码来源:ModelProgram.py


注:本文中的model.Model.post_init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。