本文整理汇总了Python中moose.utils.dump函数的典型用法代码示例。如果您正苦于以下问题:Python dump函数的具体用法?Python dump怎么用?Python dump使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dump函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getCellPath
def getCellPath(self, populationType, instanceId):
''' Given a population type and instanceId, return its path '''
try:
path = self.populationDict[populationType][1]
except KeyError as e:
utils.dump("ERROR"
, [ "Population type `{0}` not found".format(populationType)
, "Availale population in network are "
, self.populationDict.keys()
]
)
raise KeyError("Missing population type : {}".format(populationType))
except Exception as e:
raise e
try:
path = path[instanceId]
except KeyError as e:
msg = "Population type {} has no instance {}".format(
populationType
, instanceId
)
utils.dump("ERROR"
, [msg , "Available instances are" , path.keys() ]
)
raise KeyError(msg)
# Now get the path from moose path
path = path.path
if not re.match(r'(\/\w+)+', path):
raise UserWarning("{} is not a valid path".format(path))
return path
示例2: simulate
def simulate( self, simTime, simDt = 1e-3, plotDt = None ):
'''Simulate the cable '''
if plotDt is None:
plotDt = simDt / 2
self.simDt = simDt
self.plotDt = plotDt
self.setupDUT( )
# Setup clocks
utils.dump("STEP", "Setting up the clocks ... ")
moose.setClock( 0, self.simDt )
moose.setClock( 1, self.simDt )
moose.setClock( 2, self.simDt )
## Use clocksc
moose.useClock( 0, '/cable/##'.format(self.cablePath), 'process' )
moose.useClock( 1, '/cable/##'.format(self.cablePath), 'init' )
moose.useClock( 2, '{}/##'.format(self.tablePath), 'process' )
utils.dump("STEP"
, [ "Simulating cable for {} sec".format(simTime)
, " simDt: %s, plotDt: %s" % ( self.simDt, self.plotDt )
]
)
self.setupHSolve( )
moose.reinit( )
utils.verify( )
moose.start( simTime )
示例3: __init__
def __init__(self, path, length, diameter, args):
""" Initialize moose-compartment """
self.mc_ = None
self.path = path
# Following values are taken from Upi's chapter on Rallpacks
self.RM = args.get('RM', 4.0)
self.RA = args.get('RA', 1.0)
self.CM = args.get('CM', 0.01)
self.Em = args.get('Em', -0.065)
self.diameter = diameter
self.compLength = length
self.computeParams( )
try:
self.mc_ = moose.Compartment(self.path)
self.mc_.length = self.compLength
self.mc_.diameter = self.diameter
self.mc_.Ra = self.Ra
self.mc_.Rm = self.Rm
self.mc_.Cm = self.Cm
self.mc_.Em = self.Em
self.mc_.initVm = self.Em
except Exception as e:
utils.dump("ERROR"
, [ "Can't create compartment with path %s " % path
, "Failed with error %s " % e
]
)
raise
示例4: addProperties
def addProperties(self, pre_segment_path, post_segment_path, props, options):
'''Add properties
'''
synName = options['syn_name']
source = options['source']
target = options['target']
weight = options['weight']
threshold = options['threshold']
propDelay = options['prop_delay']
synapse = props.attrib.get('synapse_type', None)
if not synapse:
utils.dump("WARN"
, "Synapse type {} not found.".format(synapse)
, frame = inspect.currentframe()
)
raise UserWarning("Missing parameter synapse_type")
synName = synapse
weight_override = float(props.attrib['weight'])
if 'internal_delay' in props.attrib:
delay_override = float(props.attrib['internal_delay'])
else: delay_override = propDelay
if weight_override != 0.0:
self.connectUsingSynChan(synName
, pre_segment_path
, post_segment_path
, weight_override
, threshold, delay_override
)
else: pass
示例5: createInputs
def createInputs(self):
""" createInputs
Create inputs as given in NML file and attach them to moose.
"""
for inputs in self.network.findall(".//{"+nmu.nml_ns+"}inputs"):
units = inputs.attrib['units']
# This dict is to be passed to function which attach an input
# element to moose.
factors = {}
# see pg 219 (sec 13.2) of Book of Genesis
if units == 'Physiological Units':
factors['Vfactor'] = 1e-3 # V from mV
factors['Tfactor'] = 1e-3 # s from ms
factors['Ifactor'] = 1e-6 # A from microA
else:
utils.dump("NOTE", "We got {0}".format(units))
factors['Vfactor'] = 1.0
factors['Tfactor'] = 1.0
factors['Ifactor'] = 1.0
for inputElem in inputs.findall(".//{"+nmu.nml_ns+"}input"):
self.attachInputToMoose(inputElem, factors)
示例6: plotVector
def plotVector(self, vector, plotname):
''' Saving input vector to a file '''
name = plotname.replace('/', '_')
fileName = os.path.join(self.plotPaths, name)+'.eps'
utils.dump("DEBUG"
, "Saving vector to a file {}".format(fileName)
)
plt.vlines(vector, 0, 1)
plt.savefig(fileName)
示例7: createChannel
def createChannel(species, path, **kwargs):
"""Create a channel """
if species == 'na':
return sodiumChannel( path, **kwargs)
elif species == 'ca':
channel.Xpower = 4
else:
utils.dump("FATAL", "Unsupported channel type: {}".format(species))
raise RuntimeError("Unsupported species of chanel")
示例8: recordAt
def recordAt(self, depth, index):
""" Parameter index is python list-like index. Index -1 is the last
elements in the list
"""
utils.dump("RECORD", "Adding probe at index {} and depth {}".format(index, depth))
c = self.cable[depth][index]
t = moose.Table("{}/output_at_{}".format(self.tablePath, index))
moose.connect(t, "requestOut", c, "getVm")
return t
示例9: makeCable
def makeCable( self, args ):
''' Make a cable out of n compartments '''
for i in range( self.ncomp ):
compPath = '{}/comp{}'.format( self.cablePath, i)
l = self.length / self.ncomp
d = self.diameter
c = comp.MooseCompartment( compPath, l, d, args )
self.cable.append(c)
self.connect( )
utils.dump( "STEP"
, "Passive cable is connected and ready for simulation."
)
示例10: simulate
def simulate( self, simTime):
'''Simulate the cable '''
self.setupDUT( )
utils.dump("STEP"
, "Simulating cable for {} sec".format(simTime)
)
moose.reinit( )
self.setupHSolve( )
t = time.time()
moose.start( simTime )
st = time.time()
return st-t
示例11: createProjection
def createProjection(self, projection):
projectionName = projection.attrib["name"]
utils.dump("INFO", "Projection {0}".format(projectionName))
source = projection.attrib["source"]
target = projection.attrib["target"]
self.projectionDict[projectionName] = (source,target,[])
# TODO: Assuming that only one element <synapse_props> under
# <projection> element.
synProps = projection.find(".//{"+nmu.nml_ns+"}synapse_props")
options = self.addSyapseProperties(projection, synProps, source, target)
connections = projection.findall(".//{"+nmu.nml_ns+"}connection")
[self.addConnection(c, projection, options) for c in connections]
示例12: buildCable
def buildCable(self, args):
""" Build binary cable """
self.args = args
self.buildParameterLists()
# Cable is a list of lists.
self.cable = list()
for n, (l, d) in enumerate(zip(self.compLengthList, self.compDiamList)):
utils.dump("STEP", "Binary tree level {}: length {}, diameter {}".format(n, l, d))
noOfCompartments = pow(2, n)
compartmentList = []
for i in range(noOfCompartments):
compPath = "{}/comp_{}_{}".format(self.cablePath, n, i)
m = comp.MooseCompartment(compPath, l, d, args)
compartmentList.append(m.mc_)
self.cable.append(compartmentList)
self.connectCable()
示例13: configureSynChan
def configureSynChan(self, synObj, synParams={}):
'''Configure synapse. If no parameters are given then use the default
values.
'''
assert(isinstance(synObj, moose.SynChan))
utils.dump("SYNAPSE"
, "Configuring SynChan"
)
synObj.tau1 = synParams.get('tau1', 5.0)
synObj.tau2 = synParams.get('tau2', 1.0)
synObj.Gk = synParams.get('Gk', 1.0)
synObj.Ek = synParams.get('Ek', 0.0)
synObj.synapse.num = synParams.get('synapse_num', 1)
synObj.synapse.delay = synParams.get('delay', 1.0)
synObj.synapse.weight = synParams.get('weight', 1.0)
return synObj
示例14: simulate
def simulate(self, simTime, simDt, plotDt=None):
"""Simulate the cable
"""
self.simDt = simDt
self.setupDUT()
# Setup clocks
moose.setClock(0, self.simDt)
# Use clocks
moose.useClock(0, "/##", "process")
moose.useClock(0, "/##", "init")
utils.dump("STEP", ["Simulating cable for {} sec".format(simTime), " simDt: %s" % self.simDt])
utils.verify()
moose.reinit()
self.setupSolver()
moose.start(simTime)
示例15: connectWrapper
def connectWrapper(self, src, srcF, dest, destF, messageType='Single'):
"""
Wrapper around moose.connect
"""
utils.dump("INFO"
, "Connecting ({4})`\n\t{0},{1}`\n\t`{2},{3}".format(
src.path
, srcF
, dest.path
, destF
, messageType
)
, frame = inspect.currentframe()
)
try:
res = moose.connect(src, srcF, dest, destF, messageType)
assert res, "Failed to connect"
except Exception as e:
utils.dump("ERROR", "Failed to connect.")
raise e