本文整理匯總了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)