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


Python Nameable.__instances__方法代码示例

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


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

示例1: clear

# 需要导入模块: from brian2.core.names import Nameable [as 别名]
# 或者: from brian2.core.names.Nameable import __instances__ [as 别名]
def clear(erase=False):
    '''
    Stops all Brian objects from being automatically detected

    Stops objects from being tracked by `run` and `reinit`.
    Use this if you are seeing `MagicError` on repeated runs.
    
    Parameters
    ----------
    
    erase : bool, optional
        If set to ``True``, all data attributes of all Brian objects
        will be set to ``None``. This
        can help solve problems with circular references stopping objects
        from being garbage collected, and is a quick way to ensure that all
        memory associated to Brian objects is deleted.
        
    Notes
    -----
    
    Removes the objects from ``BrianObject.__instances__()`` and
    ``Nameable.__instances__()``.
    Will also set the
    `BrianObject.active` flag to ``False`` for already existing `Network`
    objects. Calls a garbage collection on completion.
    
    See ALso
    --------
    
    run, reinit, MagicError
    '''
    if erase:
        instances = set(BrianObject.__instances__())
        for obj in instances:
            obj = obj()
            if obj is None:
                continue
            for k, v in obj.__dict__.iteritems():
                object.__setattr__(obj, k, None)
    BrianObject.__instances__().clear()
    Nameable.__instances__().clear()
    gc.collect()
开发者ID:yayyme,项目名称:brian2,代码行数:44,代码来源:base.py


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