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


Python Experiment.last_instance方法代码示例

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


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

示例1: enter

# 需要导入模块: from experiment import Experiment [as 别名]
# 或者: from experiment.Experiment import last_instance [as 别名]
    def enter(self):
        # get the starting time from the parent
        self.state_time = self.get_parent_state_time()
        self.start_time = self.state_time

        # save the starting state time
        #self.log['start_time'] = self.start_time

        # add the callback to the schedule
        delay = self.state_time - now()
        if delay < 0:
            delay = 0
        if self.interval < 0:
            # schedule it for every frame
            schedule_delayed(self.callback, delay)
        else:
            # schedule the interval (0 means once)
            schedule_delayed_interval(self.callback, delay, self.interval)

        # say we're active
        self.active = True

        # update the parent time if necessary
        if self.duration > 0:
            self.advance_parent_state_time(self.duration)

        # if we don't have the exp reference, get it now
        if self.exp is None:
            from experiment import Experiment
            self.exp = Experiment.last_instance()
            
        # custom enter code
        self._enter()

        pass
开发者ID:psederberg,项目名称:smile,代码行数:37,代码来源:state.py

示例2: enter

# 需要导入模块: from experiment import Experiment [as 别名]
# 或者: from experiment.Experiment import last_instance [as 别名]
    def enter(self):
        # get the starting time from the parent
        self.state_time = self.get_parent_state_time()
        self.start_time = self.state_time

        # add the callback to the schedule
        delay = self.state_time - now()
        if delay < 0 or issubclass(self.__class__,RunOnEnter):
            # parents states (and states like Logging) run immediately
            delay = 0
        if self.interval < 0:
            # schedule it for every event loop
            schedule_delayed(self.callback, delay)
        else:
            # schedule the interval (0 means once)
            schedule_delayed_interval(self.callback, delay, self.interval)

        # say we're active
        self.active = True

        # if we don't have the exp reference, get it now
        if self.exp is None:
            from experiment import Experiment
            self.exp = Experiment.last_instance()
            
        # custom enter code
        self._enter()

        # update the parent time if necessary
        # moved to after _enter in case we update duration
        if self.duration > 0:
            self.advance_parent_state_time(self.duration)

        pass
开发者ID:eweich,项目名称:smile,代码行数:36,代码来源:state.py

示例3: __init__

# 需要导入模块: from experiment import Experiment [as 别名]
# 或者: from experiment.Experiment import last_instance [as 别名]
    def __init__(self, interval=0, parent=None, duration=0.0, 
                 save_log=True):
        """
        interval of 0 means once, -1 means every frame.
        
   		Parameters
    	----------
    	interval : {0, -1, float}
        	The number of seconds between each call.
    	parent : {None, ``ParentState``}
        	Parent state to attach to. Will search for experiment if None.
    	duration : {0.0, float}
        	Duration of the state.
    	save_log : bool
        	Whether the state logs itself.
        
        """
        self.state_time = None
        self.start_time = None
        self.end_time = None
        self.first_call_time = None
        self.first_call_error = None
        self.last_call_time = None
        self.last_call_error = None
        self.dt = None
        self.interval = interval
        self.duration = duration
        self.parent = parent
        self.active = False
        self.done = False
        self.save_log = save_log

        # get the exp reference
        from experiment import Experiment
        try:
            self.exp = Experiment.last_instance()
        except AttributeError:
            self.exp = None

        # try and set the current parent
        if self.parent is None and not self.exp is None:
            # try and get it from the exp
            self.parent = self.exp._parents[-1]

        # add self to children if we have a parent
        if self.parent:
            # append to children
            self.parent.children.append(self)

        # start the log
        self.state = self.__class__.__name__
        self.log_attrs = ['state','state_time','start_time','end_time',
                          'first_call_time','first_call_error',
                          'last_call_time','last_call_error',
                          'duration']
开发者ID:mjgilles,项目名称:smile,代码行数:57,代码来源:state.py

示例4: __init__

# 需要导入模块: from experiment import Experiment [as 别名]
# 或者: from experiment.Experiment import last_instance [as 别名]
    def __init__(self, interval=0, parent=None, duration=0.0, 
                 save_log=True):
        """
        interval of 0 means once, -1 means every frame.
        """
        self.state_time = None
        self.start_time = None
        self.end_time = None
        self.first_call_time = None
        self.first_call_error = None
        self.last_call_time = None
        self.last_call_error = None
        self.dt = None
        self.interval = interval
        self.duration = duration
        self.parent = parent
        self.active = False
        self.done = False
        self.save_log = save_log

        # get the exp reference
        from experiment import Experiment
        try:
            self.exp = Experiment.last_instance()
        except AttributeError:
            self.exp = None

        # try and set the current parent
        if self.parent is None and not self.exp is None:
            # try and get it from the exp
            self.parent = self.exp._parents[-1]

        # add self to children if we have a parent
        if self.parent:
            # append to children
            self.parent.children.append(self)

        # start the log
        self.state = self.__class__.__name__
        self.log_attrs = ['state','state_time','start_time','end_time',
                          'first_call_time','first_call_error',
                          'last_call_time','last_call_error',
                          'duration']
开发者ID:eweich,项目名称:smile,代码行数:45,代码来源:state.py

示例5: Else

# 需要导入模块: from experiment import Experiment [as 别名]
# 或者: from experiment.Experiment import last_instance [as 别名]
def Else():
    """State to attach to the else of an If state.

    """

    # get the exp reference
    from experiment import Experiment
    try:
        exp = Experiment.last_instance()
    except AttributeError:
        raise AttributeError("You must first instantiate an Experiment.")

    # find the parent
    parent = exp._parents[-1]

    # find the previous child state (-1 because this is not a state)
    prev_state = parent.children[-1]
    
    # make sure it's the If
    if not isinstance(prev_state, If):
        raise ValueError("The previous state must be an If or Elif state.")

    # return the false_state (the last out_state)
    return prev_state.out_states[-1]
开发者ID:neurodebian,项目名称:smile,代码行数:26,代码来源:state.py


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