def do_set(self): """ """ #debug ''' self.debug( ("self.",self,[ 'SettingKeyVariable', 'SettingValueVariable' ]) ) ''' #itemize first if self.SettingItemBool: #debug ''' self.debug('first we itemize') ''' #itemize self.itemize( self.SettingKeyVariable ) else: #set self.ItemizedValueMethod=None #/############################ # Case of a method get # #debug ''' self.debug( ('self.',self,['ItemizedValueMethod']) ) ''' #Check if self.ItemizedValueMethod!=None: #debug ''' self.debug('we are going to call the method but first get it') ''' #get SettedValueMethod=self[self.SettingKeyVariable] #debug ''' self.debug('SettedValueMethod is '+str(SettedValueMethod)) ''' #define try: #get SettedLiargVariablesList=SettedValueMethod.im_func.BaseDoClass.Module.getLiargVariablesList( self.SettingValueVariable ) ''' self.debug( 'SettedLiargVariablesList is '+str(SettedLiargVariablesList) ) ''' #get the method and put the value as arguments SettedValueMethod(*SettedLiargVariablesList) except: #debug ''' self.debug('call the SettedValueMethod with self.SettingValueVariable directly') ''' #direct #SettedValueMethod(*self.SettingValueVariable) SettedValueMethod(self.SettingValueVariable) #debug #Stop the setting return {"HookingIsBool":False} #/####################/# # Case of a non method with set with a set key str # elif type(self.SettingKeyVariable )==str: #/####################/# # Case of #each: set # #Check if self.SettingKeyVariable.startswith( SetEachPrefixStr ): #get SettedGetVariable=self[ SYS.deprefix( self.SettingKeyVariable, SetEachPrefixStr ) ] #Check if hasattr(SettedGetVariable,'values'): SettedGetVariablesList=SettedGetVariable.values() else: SettedGetVariablesList=SettedGetVariable #debug ''' self.debug( [ 'SettedGetVariablesList is ', SYS._str(SettedGetVariablesList), ('self.',self,['SettingValueVariable']) ] ) ''' #map map( lambda __SettedGetVariable,__SettedValueVariable: __SettedGetVariable.set( *__SettedValueVariable ) if type(__SettedValueVariable) in [ list,tuple ] and len(__SettedValueVariable)==2 else __SettedGetVariable['#map@set']( __SettedValueVariable ), SettedGetVariablesList, self.SettingValueVariable ) #Return stop the setting return {'HookingIsBool':False} #/####################/# # Case of #all: set # #Check elif self.SettingKeyVariable.startswith( SetAllPrefixStr ): #get SettedGetVariable=self[ SYS.deprefix( self.SettingKeyVariable, SetAllPrefixStr ) ] #Check if hasattr(SettedGetVariable,'values'): SettedGetVariablesList=SettedGetVariable.values() else: SettedGetVariablesList=SettedGetVariable #debug ''' self.debug( [ 'SettedGetVariablesList is ', SYS._str(SettedGetVariablesList), ('self.',self,['SettingValueVariable']) ] ) ''' #Check if type(self.SettingValueVariable) in [ list,tuple ] and len(self.SettingValueVariable)==2: #map map( lambda __SettedGetVariable: __SettedGetVariable.set( *self.SettingValueVariable ), SettedGetVariablesList ) else: #map map( lambda __SettedGetVariable: __SettedGetVariable['#map@set']( self.SettingValueVariable ), SettedGetVariablesList ) #Return stop the setting return {'HookingIsBool':False} #/####################/# # Case of a set in the __dict__ # else: #/####################/# # Case of an instancing set # #Check if self.SettingTypeBool: #debug ''' self.debug( [ 'we check if we have to set a default value here', ('self.',self,[ 'SettingKeyVariable', 'SettingValueVariable' ]) ] ) ''' #get SettedValueType=SYS.getTypeClassWithTypeStr( SYS.getTypeStrWithKeyStr( self.SettingKeyVariable) ) #Check if SettedValueType!=type(self.SettingValueVariable): #debug ''' self.debug( [ 'SettedValueType is '+str(SettedValueType) ] ) ''' #Check if SettedValueType!=None.__class__: #debug self.debug( [ 'we wrap the setting value', ('self.',self,['SettingValueVariable']) ] ) #alias ''' try: ''' #map set self.SettingValueVariable=SettedValueType( )['#map@set']( self.SettingValueVariable ) ''' except: #debug self.debug( [ 'set failed because the suffix str indicates a different type from the value', 'SettedValueType is '+str(SettedValueType), 'type(self.SettingValueVariable) is '+str( type(self.SettingValueVariable)) ] ) ''' #debug ''' self.debug( [ 'we just set in the __dict__', ('self.',self,[ 'SettingKeyVariable', 'SettingValueVariable' ]) ] ) ''' #map ''' if type(self.SettingKeyVariable)==SYS.MapListClass: #map map( lambda __MappedVariable: self.__setitem__( *__MappedVariable ), self.SettingKeyVariable ) #Return an output dict return {"HookingIsBool":False} else: ''' #__setitem__ in the __dict__, this is an utility set self.__dict__[ self.SettingKeyVariable ]=self.SettingValueVariable #add in the SettingValue try: self.SettingValueVariable.SetTagStr=self.SettingKeyVariable #self.SettingValueVariable.SetDeriveSetter=self except: pass #Return return {'HookingIsBool':False} #/####################/# # Case of a non method with set with a set dict # elif hasattr(self.SettingKeyVariable,'items'): #debug self.debug( [ 'SettingKeyVariable has items...', ('self.',self,['SettingKeyVariable']) ] ) try: #debug self.debug( 'We set with a SetKeyVariable' ) #set self.set( self.SettingKeyVariable['SetKeyVariable'], self.SettingValueVariable ) #delete del self.SettingKeyVariable['SetKeyVariable'] except: #debug self.debug( 'We set with a SetKeyVariable' ) #set self.set( self.SettingKeyVariable['SetKeyVariable'], SYS.update( self.SettingKeyVariable, self.SettingValueVariable ) ) #delete del self.SettingKeyVariable['SetKeyVariable'] #Return return {'HookingIsBool':False}
def do_point(self): #/####################/# # Adapt the type for getting things to point # #debug ''' self.debug( [ 'Adapt the type for getting things to point', ("self.",self,[ 'PointingKeyVariable', ]) ] ) ''' #init PointedValueVariablesList=SYS.GetList( self.PointingKeyVariable, self ) #debug self.debug( [ 'in the end, PointedValueVariablesList is ', SYS._str(PointedValueVariablesList) ] ) #/####################/# # Adapt the type for setting things in the commanded variables # #debug ''' self.debug( [ 'Adapt the type for setting things in the pointed variables', ("self.",self,['PointingSetVariable']) ] ) ''' #inits PointingSetVariablesList=SYS.SetList(self.PointingSetVariable) #debug self.debug( [ 'in the end, PointingSetVariablesList is ', SYS._str(PointingSetVariablesList) ] ) #/####################/# # Now store all this things in the outlets team # #debug self.debug( [ 'Now we team all that stuff' ] ) #get PointedDeriveParenterVariable= self.TeamDict[ self.PointingOutTeamStr ].manage( self.getManagingKeyStr(self.PointingKeyVariable), SYS.update( [('PointVariablesList',PointedValueVariablesList)], __PointingSetVariable, ), _ValueClass=self.PointingValueClass ) #map map( lambda __PointedValueVariable,__PointingSetVariable: , PointedValueVariablesList, PointingSetVariablesList )
#ImportModules import ShareYourSystem as SYS #set the size N=50 MyDataFrame=SYS.update( SYS.pandas.DataFrame(index=range(N)), { 'x':SYS.numpy.random.randn(N), 'y':SYS.numpy.random.randn(N), 'z':SYS.numpy.random.randn(N) } ) #figure MyFigurer=SYS.FigurerClass( )['#map@set']( { 'MyDataFrame':MyDataFrame, 'FiguringDrawVariable': [ ( '#plot', { '#liarg:#map@get':['MyDataFrame.x','MyDataFrame.y'], '#kwarg':{ 'linestyle':"", 'marker':'o', 'color':'b', 'mec':'k',
def do_connect(self): #/####################/# # Get the connected variable # #debug self.debug( [ 'Adapt the type for getting things to connect', '(if we need to get)', ("self.",self,[ 'ConnectingKeyVariable', 'ConnectingOutSetVariable', 'ConnectingGetBool', ]) ] ) #Check if self.ConnectingGetBool: #init ConnectedValueVariable=self[self.ConnectingKeyVariable] else: #alias ConnectedValueVariable=self.ConnectingKeyVariable #debug ''' self.debug( [ 'in the end, ConnectedValueVariable is ', SYS._str(ConnectedValueVariable) ] ) ''' #/####################/# # Make it parent if it was not yet the case # #debug ''' self.debug( [ 'We make the ConnectedValueVariable parentUp', 'ConnectedValueVariable is ', SYS._str(ConnectedValueVariable), ('ConnectedValueVariable.',ConnectedValueVariable,[ 'ParentedTotalPathStr' ]) ] ) ''' #parentUp ConnectedValueVariable.parentUp() #debug ''' self.debug( [ 'Ok it has connected', ('ConnectedValueVariable.',ConnectedValueVariable,[ 'ParentedTotalPathStr' ]) ] ) ''' #/####################/# # Adapt the type for setting things in the commanded variables # #debug self.debug( [ 'Adapt the type for setting things in the outlet managed connected variable', ("self.",self,[ 'ConnectingOutSetVariable' ]) ] ) #inits ConnectedOutSetVariablesList=SYS.SetList(self.ConnectingOutSetVariable) #debug ''' self.debug( [ 'in the end, ConnectedOutSetVariablesList is ', SYS._str(ConnectingSetVariablesList), 'Now adapt the type for setting things in the outlet managed connected variable', ("self.",self,[ 'ConnectingOutSetVariable' ]) ] ) ''' #inits ConnectingInSetVariablesList=SYS.SetList(self.ConnectingInSetVariable) #debug ''' self.debug( [ 'in the end, ConnectingInSetVariablesList is ', SYS._str(ConnectingSetVariablesList) ] ) ''' #/####################/# # Now put this getted variable in a # encapsulating managed outlets variable #debug ''' self.debug( [ 'Now we out team ', ('self.',self,['ConnectingOutTeamKeyStr']), 'Check if we have to set a new managed point object or just set the ', 'ConnectToVariable' ] ) ''' #Check if self.ConnectingOutTeamKeyStr=="": #debug self.debug( [ 'We just set the ConnectToVariable' ] ) #set self.ConnectToVariable=ConnectedValueVariable #update if len(ConnectedOutSetVariablesList)>0: #mapSet self.mapSet( ConnectedOutSetVariablesList ) else: #debug ''' self.debug( [ 'We set in a team' ] ) ''' #Check if self.ConnectingOutTeamKeyStr not in self.TeamDict: ConnectedOutDeriveTeamer=self.team( self.ConnectingOutTeamKeyStr ).TeamedValueVariable else: ConnectedOutDeriveTeamer=self.TeamDict[ self.ConnectingOutTeamKeyStr ] #/####################/# # Build the OutManagementKeyStr # #Check if self.ConnectingOutManagementKeyStr=="": #set ConnectedOutManagementKeyStr=ConnectManagementPrefixStr+ConnectedValueVariable.ParentedTotalPathStr.replace( '/','_' )+'_'+ConnectedValueVariable.ManagementTagStr else: #alias ConnectedOutManagementKeyStr=self.ConnectingOutManagementKeyStr #/####################/# # Now manage # #debug ''' self.debug( [ 'We manage out', ('self.',self,[ 'ConnectingValueClass', ]), 'ConnectedOutSetVariablesList is ', SYS._str(ConnectedOutSetVariablesList) ] ) ''' #manage if self.ConnectingValueClass!=None: ConnectedOutDeriveTeamer.ManagingValueClass=self.ConnectingValueClass #manage ConnectedOutDeriveTeamer.manage( ConnectedOutManagementKeyStr, SYS.update( [ ('ConnectToVariable',ConnectedValueVariable), ('ConnectFromVariable',self) ], ConnectedOutSetVariablesList, ), ) #/####################/# # And put also the inverse in a # encapsulating managed inlets in the getted variable #debug ''' self.debug( [ 'Now we in team ', 'IMPORTANT the ConnectingInTeamKeyStr is from the original connecting', 'not the connected object', ('self.',self,['ConnectingInTeamKeyStr']) ] ) ''' #Check if self.ConnectingInTeamKeyStr=="": #debug ''' self.debug( [ 'We just set the ConnectFromVariable in the ConnectedValueVariable' ] ) ''' #set ConnectedValueVariable.ConnectFromVariable=self #update if len(ConnectingInSetVariablesList)>0: #mapSet ConnectedValueVariable.mapSet( ConnectedInSetVariablesList ) else: #debug self.debug( [ 'We set a team in the ConnectFromVariable' ] ) #Check if self.ConnectingInTeamKeyStr not in ConnectedValueVariable.TeamDict: ConnectedInDeriveTeamer=ConnectedValueVariable.team( self.ConnectingInTeamKeyStr ).TeamedValueVariable else: ConnectedInDeriveTeamer=ConnectedValueVariable.TeamDict[ self.ConnectingInTeamKeyStr ] #/####################/# # Build the InManagementKeyStr # #Check if self.ConnectingInManagementKeyStr=="": ConnectedInManagementKeyStr=ConnectManagementPrefixStr+self.ParentedTotalPathStr.replace( '/','_' )+'_'+self.ManagementTagStr else: ConnectedInManagementKeyStr=self.ConnectingInManagementKeyStr #/####################/# # Now manage # #debug ''' self.debug( [ 'manage the connect in', ('self.',self,['ConnectingValueClass']) ] ) ''' #Check if self.ConnectingValueClass!=None: #set ConnectedInDeriveTeamer.ManagingValueClass=self.ConnectingValueClass #manage ConnectedInDeriveTeamer.manage( ConnectedInManagementKeyStr, SYS.update( [ ('ConnectToVariable',self), ('ConnectFromVariable',ConnectedValueVariable) ], ConnectingInSetVariablesList, ), )
def do_explore(self): """ """ #debug ''' self.debug( [ "We explore here" ] ) ''' #Check if self.ExploredSucessesInt < self.ExploringSuccessesInt: # # Prepare # #Check if hasattr(self.ExploringRangeVariable,'items'): self.ExploredRangeTuplesList=self.ExploringRangeVariable.items() #Check if hasattr(self.ExploringConditionVariable,'items'): self.ExploredConditionTuplesList=self.ExploringConditionVariable.items() #Check if len(self.ExploredRangeTuplesList)!=len(self.ExploredParameterStrsList): self.ExploredParameterStrsList = map( lambda __TuplesList:__TuplesList[0], self.ExploredRangeTuplesList ) # # Prepare Children # #Check if self.ExploredManagersVariable == None: #debug self.debug( [ ('self.',self,[ 'TeamingClassesDict' ]) ] ) #sum self.ExploredManagersVariable = SYS.sum( SYS.filterNone( map( lambda __TeamStr: self.TeamDict[__TeamStr].ManagementDict.values() if __TeamStr in self.TeamDict else None, self.TeamingClassesDict.keys() ) ) ) #Check if self.ParentDeriveTeamerVariable == None: #coordinate one first time self.coordinate(self.ExploringMethodStr) #set ExploredTopMethodStr=self.ExploringMethodStr+"Top" #Check if hasattr(self,ExploredTopMethodStr): #set self.ExploredMethodStr = ExploredTopMethodStr if self.ExploredMethodStr=="": self.ExploredMethodStr = self.ExploringMethodStr # # Pick # #Check while self.ExploringTrialsInt > self.ExploredTrialsInt : #count self.ExploredTrialsInt +=1 #debug ''' self.debug( [ "We test with a new trial set", ('self.',self,[ 'ExploredTrialsInt' ]) ] ) ''' # # Init # #init the ranges map( lambda __TuplesList: setattr( self, __TuplesList[0], __TuplesList[1](self) ), self.ExploredRangeTuplesList ) # # Check Children # #debug self.debug( [ "We first check the children" ] ) #map map( lambda __Manager: __Manager.explore( _MethodStr = self.ExploringMethodStr, _ConditionVariable = SYS.update( self.ExploringConditionVariable, { "explore":getattr( self.__class__, self.ExploringMethodStr+__Manager.CoordinatedParentSingularStr ) } ) if hasattr(__Manager,self.ExploringMethodStr+__Manager.CoordinatedParentSingularStr) else self.ExploringConditionVariable, _SuccessesInt=1 ) if __Manager.ExploredCheckBool==False else None, self.ExploredManagersVariable ) # # Test # #debug self.debug( [ "Now we do the local test", ('self.',self,[ 'ExploringMethodStr', 'ExploredMethodStr' ]) ] ) #call getattr(self,self.ExploredMethodStr)() # # Each Check # #init self.ExploredCheckBool = True #loop for __ConditionTuple in self.ExploredConditionTuplesList: #Check if __ConditionTuple[1](self) == False: #set self.ExploredCheckBool = False #break break #debug ''' self.debug( [ ('self.',self,[ 'ExploredCheckBool' ]) ] ) ''' # # Total Check # #Check if self.ExploredCheckBool: #count self.ExploredSucessesInt += 1 #keep self.ExploredStoreTuplesListsList.append( map( lambda __KeyStr: (__KeyStr,getattr(self,__KeyStr)), self.ExploredKeepStrsList+self.ExploredParameterStrsList ) ) #debug ''' self.debug( [ "it is a sucess", ('self.',self,['ExploredStoreTuplesListsList']) ] ) ''' #break maybe if self.ExploredSucessesInt >= self.ExploringSuccessesInt: #break break #debug ''' self.debug( [ ('We reached the max of Trials ot pick') ] ) ''' else: #debug '''
def do_point(self): #/####################/# # Get the pointed variable # #debug ''' self.debug( [ 'Adapt the type for getting things to point', '(if we need to get)', ("self.",self,[ 'PointingKeyVariable', 'PointingOutSetVariable', 'PointingGetBool', ]) ] ) ''' #Check if self.PointingGetBool: #init PointedValueVariable=self[self.PointingKeyVariable] else: #alias PointedValueVariable=self.PointingKeyVariable #debug ''' self.debug( [ 'in the end, PointedValueVariable is ', SYS._str(PointedValueVariable) ] ) ''' #/####################/# # Make it parent if it was not yet the case # #debug ''' self.debug( [ 'We make the PointedValueVariable parentUp', 'PointedValueVariable is ', SYS._str(PointedValueVariable), ('PointedValueVariable.',PointedValueVariable,[ 'ParentedTotalPathStr' ]) ] ) ''' #parentUp PointedValueVariable.parentUp() #debug ''' self.debug( [ 'Ok it has pointed', ('PointedValueVariable.',PointedValueVariable,[ 'ParentedTotalPathStr' ]) ] ) ''' #/####################/# # Adapt the type for setting things in the commanded variables # #debug ''' self.debug( [ 'Adapt the type for setting things in the outlet managed pointed variable', ("self.",self,[ 'PointingOutSetVariable' ]) ] ) ''' #inits PointingOutSetVariablesList=SYS.SetList(self.PointingOutSetVariable) #debug ''' self.debug( [ 'in the end, PointingOutSetVariablesList is ', SYS._str(PointingSetVariablesList), 'Now adapt the type for setting things in the outlet managed pointed variable', ("self.",self,[ 'PointingOutSetVariable' ]) ] ) ''' #inits PointingInSetVariablesList=SYS.SetList(self.PointingInSetVariable) #debug ''' self.debug( [ 'in the end, PointingInSetVariablesList is ', SYS._str(PointingSetVariablesList) ] ) ''' #/####################/# # Now put this getted variable in a # encapsulating managed outlets variable #debug ''' self.debug( [ 'Now we out team ' ] ) ''' #Check if self.PointingOutTeamKeyStr not in self.TeamDict: PointedOutDeriveTeamer=self.team( self.PointingOutTeamKeyStr ).TeamedValueVariable else: PointedOutDeriveTeamer=self.TeamDict[ self.PointingOutTeamKeyStr ] #/####################/# # Build the OutManagementKeyStr # #Check if self.PointingOutManagementKeyStr=="": PointedOutManagementKeyStr=PointManagementPrefixStr+PointedValueVariable.ParentedTotalPathStr.replace( '/','_' )+'_'+PointedValueVariable.ManagementTagStr else: PointedOutManagementKeyStr=self.PointingOutManagementKeyStr #/####################/# # Now manage # #debug ''' self.debug( [ 'We manage out', ('self.',self,['PointingValueClass']) ] ) ''' #manage if self.PointingValueClass!=None: PointedOutDeriveTeamer.manage( PointedOutManagementKeyStr, SYS.update( [ ('PointToVariable',PointedValueVariable), ('PointFromVariable',self) ], PointingOutSetVariablesList, ), _ValueClass=self.PointingValueClass ) else: PointedOutDeriveTeamer.manage( PointedOutManagementKeyStr, SYS.update( [ ('PointToVariable',PointedValueVariable), ('PointFromVariable',self) ], PointingOutSetVariablesList, ), ) #/####################/# # And put also the inverse in a # encapsulating managed inlets in the getted variable #debug ''' self.debug( [ 'Now we in team ', 'IMPORTANT the PointingInTeamKeyStr is from the original pointing', 'not the pointed object', ('self.',self,['PointingInTeamKeyStr']) ] ) ''' #Check if self.PointingInTeamKeyStr not in PointedValueVariable.TeamDict: PointedInDeriveTeamer=PointedValueVariable.team( self.PointingInTeamKeyStr ).TeamedValueVariable else: PointedInDeriveTeamer=PointedValueVariable.TeamDict[ self.PointingInTeamKeyStr ] #/####################/# # Build the InManagementKeyStr # #Check if self.PointingInManagementKeyStr=="": PointedInManagementKeyStr=PointManagementPrefixStr+self.ParentedTotalPathStr.replace( '/','_' )+'_'+self.ManagementTagStr else: PointedInManagementKeyStr=self.PointingInManagementKeyStr #/####################/# # Now manage # #debug ''' self.debug( [ 'manage the point in', ('self.',self,['PointingValueClass']) ] ) ''' #Check if self.PointingValueClass!=None: #manage PointedInDeriveTeamer.manage( PointedInManagementKeyStr, SYS.update( [ ('PointToVariable',self), ('PointFromVariable',PointedValueVariable) ], PointingInSetVariablesList, ), _ValueClass=self.PointingValueClass ) else: #manage PointedInDeriveTeamer.manage( PointedInManagementKeyStr, SYS.update( [ ('PointToVariable',self), ('PointFromVariable',PointedValueVariable) ], PointingInSetVariablesList, ), )