def viewEvent(self): # debug """ self.debug( [ 'We complete a view so first fill the draw' ] ) """ # set self.ViewedLabelStr = ( "$" + self.ManagementTagStr + "_{" + str(self.BrianedParentPopulationDeriveBrianerVariable.BrianedNeurongroupVariable.name).replace("_", "/") + "}" ) # set self.PyplotingDrawVariable = [ ( "plot", { "#liarg:#map@get": [ "#IdGetStr.BrianedSpikeMonitorVariable.t", ">>SYS.IdDict[#IdStr].BrianedSpikeMonitorVariable.i", ], "#kwarg": dict( {"label": self.ViewedLabelStr, "linestyle": "", "marker": ".", "color": "b"}, **self.BrianingPyplotDict ), }, ) ] # /####################/# # maybe replace Chart also # # debug """ self.debug( [ 'Before replace', ('self.',self,[ 'PyplotingDrawVariable', 'PyplotingChartVariable' ]) ] ) """ # mapReplace [self.PyplotingDrawVariable, self.PyplotingChartVariable] = map( lambda __Variable: SYS.replace( __Variable, {"#IdStr": str(self.PrintIdInt), "#IdGetStr": "#id:" + str(self.PrintIdInt)}, self ) if __Variable != None else None, map(lambda __KeyStr: getattr(self, __KeyStr), ["PyplotingDrawVariable", "PyplotingChartVariable"]), ) # debug """ self.debug( [ 'After replace', ('self.',self,[ #'PyplotingDrawVariable', 'PyplotingChartVariable' ]) ] ) """ # /####################/# # Update maybe the # parent neuron group # get BrianedChartDeriveManager = self.BrianedParentPopulationDeriveBrianerVariable.TeamDict["Charts"] # manage BrianedChartDerivePyploter = BrianedChartDeriveManager.manage(self.ManagementTagStr).ManagedValueVariable # debug """ self.debug( [ 'We update in the parent neurongroup chart', 'BrianedChartDerivePyploter is ', SYS._str(BrianedChartDerivePyploter), ('self.',self,[]) ] ) """ # team BrianedDrawDeriveManager = BrianedChartDerivePyploter.team("Draws").TeamedValueVariable # manage BrianedDrawDeriveManager.manage( str(self.ManagementIndexInt), {"PyplotingDrawVariable": self.PyplotingDrawVariable} )
def viewSample(self): # debug self.debug( [ "We complete a view so first fill the draw", ("self.", self, ["RecordingLabelVariable", "ViewedLegendLabelStr"]), ] ) # /##################/# # Determine the way of labeling the variable names # # set if self.ViewedLegendLabelStr == "": # set self.ViewedLegendLabelStr = "$" + self.BrianedParentDeriveRecorderVariable.RecordKeyStr """ self.ViewedLegendLabelStr+='_{'+str( #self.BrianedParentPopulationDeriveBrianerVariable.BrianedNeurongroupVariable.name #self.BrianedParentPopulationDeriveBrianerVariable.BrianedNeurongroupVariable. ).replace('_','/')+'}' """ # debug self.debug(["We have specified the legend label", ("self.", self, ["ViewedLegendLabelStr"])]) # set self.PyplotingDrawVariable = map( lambda __IndexInt: ( "plot", { "#liarg:#map@get": [ "#IdGetStr.BrianedStateMonitorVariable.t", ">>SYS.IdDict[#IdStr].BrianedStateMonitorVariable." + self.BrianedParentDeriveRecorderVariable.RecordKeyStr + "[" + str(__IndexInt) + ",:]", ], "#kwarg": dict( { "label": self.ViewedLegendLabelStr + "^{" + str(__IndexInt) + "}$", "linestyle": "-", "color": "b", }, **self.BrianingPyplotDict ), }, ), self.RecordingLabelVariable, ) # /####################/# # maybe set for the Chart # # init self.PyplotingChartVariable = [] # /####################/# # maybe set the X Chart also # # get BrianedTimeUnit = self.BrianedStateMonitorVariable.t.unit # scale # self.ViewingXVariable=self.BrianedStateMonitorVariable.t[:] self.ViewingXVariable = self.BrianedStateMonitorVariable.t / ( # (1./self.ViewingXScaleFloat)*BrianedTimeUnit BrianedTimeUnit ) # set self.ViewingXLabelStr = "$t\ (" + str((1.0 / self.ViewingXScaleFloat) * BrianedTimeUnit).split(".")[-1] + ")$" # /####################/# # maybe set the Y Chart also # # debug self.debug( [ "We set the y axis", "self.BrianedParentDeriveRecorderVariable.RecordedTraceFloatsArray is ", str(self.BrianedParentDeriveRecorderVariable.RecordedTraceFloatsArray), ] ) # import import brian2 # get ViewingYVariable = getattr( self.BrianedStateMonitorVariable, self.BrianedParentDeriveRecorderVariable.RecordKeyStr ) # split # BrianedDimensionStr=str(ViewingYVariable).split(' ')[-1] BrianedActivityUnit = getattr( self.BrianedParentPopulationDeriveBrianerVariable.BrianedNeurongroupVariable, self.BrianedParentDeriveRecorderVariable.RecordKeyStr, ).unit # divide # self.ViewingYVariable=ViewingYVariable/getattr( # brian2,BrianedDimensionStr # ) self.ViewingYVariable = ViewingYVariable / (BrianedActivityUnit) # self.ViewingYVariable=ViewingYVariable self.ViewingYVariable = self.ViewingYVariable[:] print (self.ViewingYVariable) # set self.ViewingYLabelStr = "$" + self.BrianedParentDeriveRecorderVariable.RecordKeyStr """ self.ViewingYLabelStr+='_{'+str( self.BrianedParentPopulationDeriveBrianerVariable.BrianedNeurongroupVariable.name ).replace('_','/')+'}(t)\ ('+str( self.BrianedParentDeriveRecorderVariable.RecordedTraceFloatsArray.unit )+')' """ # self.ViewingYLabelStr+='\ ('+BrianedDimensionStr+')' self.ViewingYLabelStr += "\ (" + str((1.0 / self.ViewingYScaleFloat) * BrianedActivityUnit).split(".")[-1] + ")" self.ViewingYLabelStr += "$" # /################/# # call the base view method # # debug self.debug([("self.", self, ["ViewingXVariable", "ViewingYVariable"]), "Now we call the view"]) # call BaseClass.view(self) # /####################/# # maybe set global Chart also # self.PyplotingChartVariable += [ ("tick_params", {"#kwarg": {"length": 10, "width": 5, "which": "major"}}), ("tick_params", {"#kwarg": {"length": 5, "width": 2, "which": "minor"}}), ("xaxis.set_ticks_position", {"#liarg": ["bottom"]}), ("yaxis.set_ticks_position", {"#liarg": ["left"]}), ( "legend", { "#liarg": [], "#kwarg": { "fontsize": 10, "shadow": True, "fancybox": True, "ncol": max( 1, len( getattr( self.BrianedStateMonitorVariable, self.BrianedParentDeriveRecorderVariable.RecordKeyStr, ) ) / 2, ), "loc": 2, "bbox_to_anchor": (1.05, 1), }, }, ), ] # /####################/# # maybe replace Chart also # # debug """ self.debug( [ 'Before replace', ('self.',self,[ 'PyplotingDrawVariable', 'PyplotingChartVariable' ]) ] ) """ # mapReplace [self.PyplotingDrawVariable, self.PyplotingChartVariable] = map( lambda __Variable: SYS.replace( __Variable, {"#IdStr": str(self.PrintIdInt), "#IdGetStr": "#id:" + str(self.PrintIdInt)}, self ) if __Variable != None else None, map(lambda __KeyStr: getattr(self, __KeyStr), ["PyplotingDrawVariable", "PyplotingChartVariable"]), ) # debug """ self.debug( [ 'After replace', ('self.',self,[ #'PyplotingDrawVariable', 'PyplotingChartVariable' ]) ] ) """ # /####################/# # Update maybe the # parent neuron group # debug self.debug(["Maybe we also update the view in the parent population"]) # Check if "Charts" in self.BrianedParentPopulationDeriveBrianerVariable.TeamDict: # get BrianedChartsDeriveManager = self.BrianedParentPopulationDeriveBrianerVariable.TeamDict["Charts"] # manage BrianedChartDerivePyploter = BrianedChartsDeriveManager.manage( self.BrianedParentDeriveRecorderVariable.ManagementTagStr ).ManagedValueVariable # debug """ self.debug( [ 'We update in the parent neurongroup chart', 'BrianedChartDerivePyploter is ', SYS._str(BrianedChartDerivePyploter), ('self.',self,[]) ] ) """ # team BrianedDrawDeriveManager = BrianedChartDerivePyploter.team("Draws").TeamedValueVariable # manage BrianedDrawDeriveManager.manage( str(self.ManagementIndexInt), {"PyplotingDrawVariable": self.PyplotingDrawVariable} )
def brianSample(self): #debug self.debug( [ 'It is a Sample State Moniter level', ('self.',self,[ 'MoniteringLabelIndexIntsArray', ]) ] ) #/####################/# # Set the parent # #get self.BrianedParentDeriveRecorderVariable=self.ParentDeriveTeamerVariable.ParentDeriveTeamerVariable #get self.BrianedParentNeurongroupDeriveBrianerVariable=self.BrianedParentDeriveRecorderVariable.BrianedParentNeurongroupDeriveBrianerVariable #get self.BrianedParentNetworkDeriveBrianerVariable=self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedParentNetworkDeriveBrianerVariable #/####################/# # Set the brian monitor # #debug ''' self.debug( [ 'We set the state monitor', ('self.',self,[ #'BrianedParentNeurongroupDeriveBrianerVariable' ]), #'self.BrianedParentDeriveRecorderVariable.RecordKeyStr is ', #str(self.BrianedParentDeriveRecorderVariable.RecordKeyStr) 'self.ParentedTotalManagementOrderedDict.keys() is ', str(self.ParentedTotalManagementOrderedDict.keys()) ] ) ''' #import from brian2 import StateMonitor #init self.BrianedStateMonitorVariable=StateMonitor( self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable, self.BrianedParentDeriveRecorderVariable.RecordKeyStr, self.MoniteringLabelIndexIntsArray, ) #debug ''' self.debug( [ 'Ok we have setted the monitor', ('self.',self,['BrianedStateMonitorVariable']), 'Now we add to the structure', 'self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable is ', str(self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable) ] ) ''' #/####################/# # add to the structure # #debug ''' self.debug( [ 'We add to the structure' ] ) ''' #add self.BrianedParentNetworkDeriveBrianerVariable.BrianedNetworkVariable.add( self.BrianedStateMonitorVariable ) #/####################/# # maybe pyplot a draw plot # #debug self.debug( [ 'Maybe we pyplot' ] ) #Check if self.BrianingPyplotBool: #debug ''' self.debug( [ 'We complete a view so first fill the draw' ] ) ''' #set LabelStr='$'+self.BrianedParentDeriveRecorderVariable.RecordKeyStr+'_{'+str( self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable.name ).replace('_','/')+'}' #set self.PyplotingDrawVariable=map( lambda __IndexInt: ( 'plot', { '#liarg:#map@get':[ '#IdGetStr.BrianedStateMonitorVariable.t', '>>SYS.IdDict[#IdStr].BrianedStateMonitorVariable.'+self.BrianedParentDeriveRecorderVariable.RecordKeyStr+'['+str( __IndexInt)+',:]' ], '#kwarg':dict( { 'label':LabelStr+'^{'+str(__IndexInt)+'}$', 'linestyle':'-', 'color':'b' }, **self.BrianingPyplotDict ) } ), self.MoniteringLabelIndexIntsArray ) #/####################/# # maybe set for the Chart # #init self.PyplotingChartVariable=[] #/####################/# # maybe set the X Chart also # #Check if self.BrianedParentNeurongroupDeriveBrianerVariable.BrianingTimeDimensionVariable==None: from brian2 import ms self.BrianedParentNeurongroupDeriveBrianerVariable.BrianingTimeDimensionVariable=ms #set XLabelStr='$t\ ('+str( self.BrianedParentNeurongroupDeriveBrianerVariable.BrianingTimeDimensionVariable )+')$' #set SampleTagStr=self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable.name+'t' #join XlimLiargStr="".join([ ">>SYS.set(SYS,'"+SampleTagStr+"LimFloatsArray',", "[SYS.IdDict[#IdStr].BrianedStateMonitorVariable.t[:].min(),", "SYS.IdDict[#IdStr].BrianedStateMonitorVariable.t[:].max()]", ').'+SampleTagStr+"LimFloatsArray" ]) #join XticksLiargStr="".join([ ">>SYS.set(SYS,'"+SampleTagStr+"TickFloatsArray',", "map(lambda __Float:float('%.2f'%__Float),", "SYS.getTickFloatsArray(", 'SYS.'+SampleTagStr+"LimFloatsArray,3", ")))."+SampleTagStr+"TickFloatsArray" ]) XtickLabelLiargStr="".join([ ">>SYS.set(SYS,'"+SampleTagStr+"TickStrsArray',", "map(lambda __Float:'$'+str(__Float)+'$',", "SYS."+SampleTagStr+"TickFloatsArray))."+SampleTagStr+"TickStrsArray" ]) #debug ''' self.debug( [ 'XLabelStr is ', XLabelStr, 'XlimLiargStr is', XlimLiargStr, 'XticksLiargStr is ', XticksLiargStr, 'XtickLabelLiargStr is ', XtickLabelLiargStr ] ) ''' #set self.PyplotingChartVariable+=[ ( 'set_xlabel',XLabelStr ), ( 'set_xlim',{ '#liarg:#map@get':[XlimLiargStr] } ), ( 'set_xticks',{ '#liarg:#map@get':[XticksLiargStr] } ), ( 'set_xticklabels',{ '#liarg:#map@get':[XtickLabelLiargStr] } ) ] #/####################/# # maybe set the Y Chart also # #set YLabelStr='$'+self.BrianedParentDeriveRecorderVariable.RecordKeyStr+'_{'+str( self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable.name ).replace('_','/')+'}(t)\ ('+str( self.BrianedParentDeriveRecorderVariable.RecordedTraceFloatsArray.unit )+')$' #set SampleTagStr=self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable.name+self.BrianedParentDeriveRecorderVariable.RecordKeyStr #join YlimLiargStr="".join([ ">>SYS.set(SYS,'"+SampleTagStr+"LimFloatsArray',", "[SYS.IdDict[#IdStr].BrianedStateMonitorVariable."+self.BrianedParentDeriveRecorderVariable.RecordKeyStr+".min(),", "SYS.IdDict[#IdStr].BrianedStateMonitorVariable."+self.BrianedParentDeriveRecorderVariable.RecordKeyStr+".max()]", ').'+SampleTagStr+"LimFloatsArray" ]) #join YticksLiargStr="".join([ ">>SYS.set(SYS,'"+SampleTagStr+"TickFloatsArray',", "map(lambda __Float:float('%.2f'%__Float),", "SYS.getTickFloatsArray(", 'SYS.'+SampleTagStr+"LimFloatsArray,3", ")))."+SampleTagStr+"TickFloatsArray" ]) YtickLabelLiargStr="".join([ ">>SYS.set(SYS,'"+SampleTagStr+"TickStrsArray',", "map(lambda __Float:'$'+str(__Float)+'$',", "SYS."+SampleTagStr+"TickFloatsArray))."+SampleTagStr+"TickStrsArray" ]) #debug ''' self.debug( [ 'YLabelStr is ', YLabelStr, 'YlimLiargStr is', YlimLiargStr, 'YticksLiargStr is ', YticksLiargStr, 'YtickLabelLiargStr is ', YtickLabelLiargStr ] ) ''' #set self.PyplotingChartVariable+=[ ( 'set_ylabel',YLabelStr ), ( 'set_ylim',{ '#liarg:#map@get':[YlimLiargStr] } ), ( 'set_yticks',{ '#liarg:#map@get':[YticksLiargStr] } ), ( 'set_yticklabels',{ '#liarg:#map@get':[YtickLabelLiargStr] } ) ] #/####################/# # maybe set global Chart also # self.PyplotingChartVariable+=[ ( 'tick_params',{ '#kwarg':{ 'length':10, 'width':5, 'which':'major' } } ), ( 'tick_params',{ '#kwarg':{ 'length':5, 'width':2, 'which':'minor' } } ), ('xaxis.set_ticks_position', { '#liarg':['bottom'] } ), ('yaxis.set_ticks_position', { '#liarg':['left'] } ), ('legend',{ '#liarg':[], '#kwarg':{ 'fontsize':10, 'shadow':True, 'fancybox':True, 'ncol':max(1,len( getattr( self.BrianedStateMonitorVariable, self.BrianedParentDeriveRecorderVariable.RecordKeyStr ) )/2), 'loc':2, 'bbox_to_anchor':(1.05, 1) } }) ] #/####################/# # maybe replace Chart also # #debug ''' self.debug( [ 'Before replace', ('self.',self,[ 'PyplotingDrawVariable', 'PyplotingChartVariable' ]) ] ) ''' #mapReplace [ self.PyplotingDrawVariable, self.PyplotingChartVariable ]=map( lambda __Variable: SYS.replace( __Variable, { '#IdStr':str(self.PrintIdInt), '#IdGetStr':"#id:"+str(self.PrintIdInt) }, self ) if __Variable!=None else None, map( lambda __KeyStr: getattr( self, __KeyStr ), [ 'PyplotingDrawVariable', 'PyplotingChartVariable' ] ) ) #debug ''' self.debug( [ 'After replace', ('self.',self,[ #'PyplotingDrawVariable', 'PyplotingChartVariable' ]) ] ) ''' #/####################/# # Update maybe the # parent neuron group """ #Check if 'Charts' not in self.BrianedParentNeurongroupDeriveBrianerVariable.TeamDict: BrianedChartsDeriveManager=self.BrianedParentNeurongroupDeriveBrianerVariable.team( 'Charts').TeamedValueVariable else: BrianedChartsDeriveManager=self.BrianedParentNeurongroupDeriveBrianerVariable.TeamDict['Charts'] """ #get BrianedChartsDeriveManager=self.BrianedParentNeurongroupDeriveBrianerVariable.TeamDict[ 'Charts' ] #get #BrianedChartDerivePyploter=BrianedChartsDeriveManager.ManagementDict[ # self.BrianedParentDeriveRecorderVariable.ManagementTagStr #] BrianedChartDerivePyploter=BrianedChartsDeriveManager.manage( self.BrianedParentDeriveRecorderVariable.ManagementTagStr ).ManagedValueVariable #debug ''' self.debug( [ 'We update in the parent neurongroup chart', 'BrianedChartDerivePyploter is ', SYS._str(BrianedChartDerivePyploter), ('self.',self,[]) ] ) ''' #team BrianedDrawDeriveManager=BrianedChartDerivePyploter.team( 'Draws' ).TeamedValueVariable #manage BrianedDrawDeriveManager.manage( str(self.ManagementIndexInt), { 'PyplotingDrawVariable':self.PyplotingDrawVariable } )
} ) ) #print print('\nThe replace gives') print( SYS.replace( { 'MyStr':"#BonjourStr Erwan #EndStr", 'MyInt':'#MyInt', 'MyTotalInt':'#get:>>#MyInt+2', 'MyDict':{ 'MyStr':'#BonjourStr' } }, { '#BonjourStr':'Salut', '#EndStr':'!', '#MyInt':1 }, SYS.PointerClass() ) ) #print with recursive dict set print('\nThe mapReplace gives') SYS._print( SYS.mapReplace( {
def brianEvent(self): #debug ''' self.debug( [ 'It is a Spike Moniter level', ('self.',self,[ ]) ] ) ''' #/####################/# # Set the BrianedParentNeurongroupDeriveBrianerVariable # #get self.BrianedParentNeurongroupDeriveBrianerVariable=self.ParentDeriveTeamerVariable.ParentDeriveTeamerVariable #get self.BrianedParentNetworkDeriveBrianerVariable=self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedParentNetworkDeriveBrianerVariable #/####################/# # Set the brian monitor # #debug ''' self.debug( [ 'We set the spike monitor' ] ) ''' #import from brian2 import SpikeMonitor #init self.BrianedSpikeMonitorVariable=SpikeMonitor( self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable, ) #debug ''' self.debug( [ 'Ok we have setted the monitor', ('self.',self,['BrianedSpikeMonitorVariable']), 'Now we add to the structure', 'self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNetworkVariable is ', str(self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNetworkVariable) ] ) ''' #/####################/# # add to the structure # #add self.BrianedParentNetworkDeriveBrianerVariable.BrianedNetworkVariable.add( self.BrianedSpikeMonitorVariable ) #/####################/# # maybe pyplot a draw plot # #Check if self.BrianingPyplotBool: #debug ''' self.debug( [ 'We complete a view so first fill the draw' ] ) ''' #set LabelStr='$'+self.ManagementTagStr+'_{'+str( self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable.name ).replace('_','/')+'}' #set self.PyplotingDrawVariable=[ ( 'plot', { '#liarg:#map@get':[ '#IdGetStr.BrianedSpikeMonitorVariable.t', '>>SYS.IdDict[#IdStr].BrianedSpikeMonitorVariable.i' ], '#kwarg':dict( { 'label':LabelStr, 'linestyle':'', 'marker':'.', 'color':'b' }, **self.BrianingPyplotDict ) } ) ] #/####################/# # maybe replace Chart also # #debug ''' self.debug( [ 'Before replace', ('self.',self,[ 'PyplotingDrawVariable', 'PyplotingChartVariable' ]) ] ) ''' #mapReplace [ self.PyplotingDrawVariable, self.PyplotingChartVariable ]=map( lambda __Variable: SYS.replace( __Variable, { '#IdStr':str(self.PrintIdInt), '#IdGetStr':"#id:"+str(self.PrintIdInt) }, self ) if __Variable!=None else None, map( lambda __KeyStr: getattr( self, __KeyStr ), [ 'PyplotingDrawVariable', 'PyplotingChartVariable' ] ) ) #debug ''' self.debug( [ 'After replace', ('self.',self,[ #'PyplotingDrawVariable', 'PyplotingChartVariable' ]) ] ) ''' #/####################/# # Update maybe the # parent neuron group #get BrianedChartDeriveManager=self.BrianedParentNeurongroupDeriveBrianerVariable.TeamDict[ 'Charts' ] #manage BrianedChartDerivePyploter=BrianedChartDeriveManager.manage( self.ManagementTagStr ).ManagedValueVariable #debug ''' self.debug( [ 'We update in the parent neurongroup chart', 'BrianedChartDerivePyploter is ', SYS._str(BrianedChartDerivePyploter), ('self.',self,[]) ] ) ''' #team BrianedDrawDeriveManager=BrianedChartDerivePyploter.team( 'Draws' ).TeamedValueVariable #manage BrianedDrawDeriveManager.manage( str(self.ManagementIndexInt), { 'PyplotingDrawVariable':self.PyplotingDrawVariable } )