本文整理汇总了Python中brian2.groups.group.Group.__getattr__方法的典型用法代码示例。如果您正苦于以下问题:Python Group.__getattr__方法的具体用法?Python Group.__getattr__怎么用?Python Group.__getattr__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类brian2.groups.group.Group
的用法示例。
在下文中一共展示了Group.__getattr__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: spatialneuron_attribute
# 需要导入模块: from brian2.groups.group import Group [as 别名]
# 或者: from brian2.groups.group.Group import __getattr__ [as 别名]
def spatialneuron_attribute(neuron, x):
'''
Selects a subtree from `SpatialNeuron` neuron and returns a `SpatialSubgroup`.
If it does not exist, returns the `Group` attribute.
'''
if x == 'main': # Main segment, without the subtrees
origin = neuron.morphology._origin
return Subgroup(neuron, origin, origin + len(neuron.morphology.x))
elif (x != 'morphology') and ((x in neuron.morphology._namedkid) or
all([c in 'LR123456789' for c in x])): # subtree
morpho = neuron.morphology[x]
return SpatialSubgroup(neuron, morpho._origin,
morpho._origin + len(morpho),
morphology=morpho)
else:
return Group.__getattr__(neuron, x)
示例2: spatialneuron_attribute
# 需要导入模块: from brian2.groups.group import Group [as 别名]
# 或者: from brian2.groups.group.Group import __getattr__ [as 别名]
def spatialneuron_attribute(neuron, name):
'''
Selects a subtree from `SpatialNeuron` neuron and returns a `SpatialSubgroup`.
If it does not exist, returns the `Group` attribute.
'''
if name == 'main': # Main section, without the subtrees
indices = neuron.morphology.indices[:]
start, stop = indices[0], indices[-1]
return SpatialSubgroup(neuron, start, stop + 1,
morphology=neuron.morphology)
elif (name != 'morphology') and ((name in getattr(neuron.morphology, 'children', [])) or
all([c in 'LR123456789' for c in name])): # subtree
morpho = neuron.morphology[name]
start = morpho.indices[0]
stop = SpatialNeuron._find_subtree_end(morpho)
return SpatialSubgroup(neuron, start, stop + 1, morphology=morpho)
else:
return Group.__getattr__(neuron, name)
示例3: __getattr__
# 需要导入模块: from brian2.groups.group import Group [as 别名]
# 或者: from brian2.groups.group.Group import __getattr__ [as 别名]
def __getattr__(self, item):
# We do this because __setattr__ and __getattr__ are not active until
# _group_attribute_access_active attribute is set, and if it is set,
# then __getattr__ will not be called. Therefore, if getattr is called
# with this name, it is because it hasn't been set yet and so this
# method should raise an AttributeError to agree that it hasn't been
# called yet.
if item == '_group_attribute_access_active':
raise AttributeError
if not hasattr(self, '_group_attribute_access_active'):
raise AttributeError
if item in self.record_variables:
unit = self.variables[item].unit
return Quantity(self.variables['_recorded_'+item].get_value().T,
dim=unit.dim, copy=True)
elif item.endswith('_') and item[:-1] in self.record_variables:
return self.variables['_recorded_'+item[:-1]].get_value().T
else:
return Group.__getattr__(self, item)