def do_scan(self): #set the ScannedGettingStrsList self.ScannedGetKeyStrsList=SYS.unzip( self.ScanningGridTuplesList,[0] ) #Scan the values of this model self.ScannedValueVariablesTuplesList=list( itertools.product(*SYS.unzip( self.ScanningGridTuplesList,[1] ) ) ) #debug self.debug(('self.',self,['ScannedGetKeyStrsList','ScannedValueVariablesTuplesList'])) #map an update and a store for each combination map( lambda __ScannedValueVariablesTuple: self.update( zip( self.ScannedGetKeyStrsList, __ScannedValueVariablesTuple ) ).setDoneVariables().collect(), self.ScannedValueVariablesTuplesList )
def do_scan(self): #<NotHook> #table first self.table() #</NotHook> #Check if len(self.ScanningRangeTuplesList)==0: #just insert self.insert() else: #set the ScannedGettingStrsList self.ScannedGetKeyStrsList=SYS.unzip( self.ScanningRangeTuplesList,[0] ) #Scan the values of this model self.ScannedValueVariablesTuplesList=list( itertools.product(*SYS.unzip( self.ScanningRangeTuplesList,[1] ) ) ) #Check if self.ScanningDatabaseKeyStr=="": self.ScanningDatabaseKeyStr=self.NodedDatabaseKeyStr #debug self.debug(('self.',self,[ 'ScanningDatabaseKeyStr', 'ScannedGetKeyStrsList', 'ScannedValueVariablesTuplesList'])) #map an update and a store for each combination self.ScannedRetrieveListsList=map( lambda __ScannedValueVariablesTuple: getattr( self.NodedDatabaseParentPointer.update( zip( self.ScannedGetKeyStrsList, __ScannedValueVariablesTuple ) ).setDoneVariables(),'NodedDatabaseOrderedDict' )[self.ScanningDatabaseKeyStr].insert().pick(['TabledInt','RowedIndexInt']), self.ScannedValueVariablesTuplesList )
def do_grid(self): #just for init self.store(_InsertIsBool=False) #grid before in all the components self.GridedComponentRetrieveListsList=map( lambda __DeriveGrider: __DeriveGrider.grid().GridedScanRetrieveListsList, self.OrganizedComponentCollectionOrderedDict.values() ) #debug self.debug(('self.',self,['GridedComponentRetrieveListsList'])) #set the GridedGettingStrsList self.GridedGetKeyStrsList=SYS.unzip( self.GridingScanTuplesList,[0] ) #scan the values of this model self.GridedValueVariablesTuplesList=list( itertools.product( *SYS.unzip( self.GridingScanTuplesList,[1] ) ) ) #set self.StoringInsertIsBool=True #map an update and a store for each combination self.GridedScanRetrieveListsList=map( lambda __GridedValueVariablesTuple: self.update( zip( self.GridedGetKeyStrsList, __GridedValueVariablesTuple ) ).store( ).OrganizedTopDeriveDatabaserVariable.pick( ['TabledInt','RowedIndexInt'] ), self.GridedValueVariablesTuplesList ) #debug '''
def mimic_row(self): #debug ''' self.debug(('self.',self,self.__class__.DoingAttributeVariablesOrderedDict.keys())) ''' #Put all the GettingStrsList in the identifying container if self.FeaturingAllBool: #debug ''' self.debug('Set the RowingGetStrsList with all the DatabasingGetStrs') ''' #set self['Attr_RowingGetStrsList']=SYS.unzip( self.DatabasingSealTuplesList, [0] ) #debug ''' self.debug(('self.',self,['RowingGetStrsList','DatabasingSealTuplesList'])) ''' #<NotHook> #row then BaseClass.row(self)
def retrieveAfter(self,**_RetrievingVariablesDict): #debug self.debug('Start of the method') #debug self.debug("self.ModeledDict['RetrievingIndexesList'] is "+str(self.ModeledDict['RetrievingIndexesList'])) #Alias RetrievedTuplesList=self.ModeledDict['RetrievedTuplesList'] #debug DebuggedStr='RetrievedTuplesList is '+str(RetrievedTuplesList) self.debug(DebuggedStr) #Definition the RetrievingIndexesListIndexInt if len(RetrievedTuplesList)>0: #Get the Index RetrievingIndexesListIndexInt=SYS.unzip(RetrievedTuplesList,[0]).index( self.ModeledDict['JoinedRetrievingIndexesListKeyStr']) #set and retrieve for the joined model self.ModeledDict['RetrievingIndexesList']=RetrievedTuplesList[RetrievingIndexesListIndexInt][1] self.retrieve(self.ModeledDict['JoinedModeledDict']['ModelStr']) #debug self.debug('End of the method')
def do_command(self): """Collect with _GatheringKeyVariablesList and do a all sets for each with _UpdatingItemVariable""" #Check if self.CommandingGatherIsBool: #Get the GatheredVariablesList self.gather() #debug ''' self.debug( ('self.',self,[ 'CommandingUpdateList', 'GatheringVariablesList', 'GatheredVariablesList' ] ) ) ''' #Check if len(self.GatheredVariablesList)>0: #Just keep the values self.CommandingGraspVariablesList=SYS.flat( SYS.unzip( self.GatheredVariablesList,[1] ) ) #debug ''' self.debug(("self.",self,['CommandingGraspVariablesList'])) ''' #Check for the order if self.CommandingOrderStr=="AllSetsForEach": #For each __GatheredVariable it is updating with _UpdatingItemVariable map( lambda __CommandedVariable: __CommandedVariable.update(self.CommandingUpdateList), self.CommandingGraspVariablesList ) elif self.CommandingOrderStr=="EachSetForAll": #For each SettingTuple it is setted in _GatheredVariablesList map( lambda __SettingVariableTuple: map( lambda __CommandedVariable: __CommandedVariable.__setitem__(*__SettingVariableTuple), self.CommandingGraspVariablesList ), self.CommandingUpdateList.items() if hasattr(self.CommandingUpdateList,'items') else self.CommandingUpdateList )
def propertize_setModelingDescriptionTuplesList(self, _SettingValueVariable): # set self._ModelingDescriptionTuplesList = _SettingValueVariable # /###################/# # Update the ModelKeyStrsList # # extend self._ModelKeyStrsList = SYS.unzip(_SettingValueVariable, [0]) # debug """ self.debug( [ 'We have binded ModelingDescriptionTuplesList to ModelKeyStrsList', ('self.',self,['ModelingDescriptionTuplesList']) ] ) """ # /###################/# # Look for items where it is a get dimension # # filter self.ModelDimensionTuplesList = map( lambda __DescriptionTuple: (__DescriptionTuple[0], __DescriptionTuple[2]), SYS._filter(lambda __DescriptionTuple: type(__DescriptionTuple[2]) in [list, tuple], _SettingValueVariable), ) # debug """
def rowBefore(self,**_RowingVariablesDict): #Check that the TabularedCalibratedTable is ok if self.TabularedCalibratedTable!=None: #set the TabularedRowedPointer self.TabularedRowedPointer=self.TabularedCalibratedTable.row #Get the ModelingTuplesList ModelingTuplesList=self.ModelingDict[ SYS.getDoingStrWithDoStr(_RowingVariablesDict['RowingStr'])+'TuplesList' ] #Get the InsertingTuplesList self.TabularedRowedTuplesList=zip( SYS.unzip(ModelingTuplesList,[0]), self.pick(SYS.unzip(ModelingTuplesList,[0])) )
def retrieve(self,**_KwargVariablesDict): #debug self.debug("self.",self,['RetrievingIndexesList','RetrievedTuplesList']) #Definition the RetrievingIndexesListIndexInt if len(self.RetrievedTuplesList)>0: #Get the Index RetrievingIndexesListIndexInt=SYS.unzip(self.RetrievedTuplesList,[0]).index( self.JoinedRetrievingIndexesListKeyStr) #set and retrieve for the joined model self.RetrievingIndexesList=self.RetrievedTuplesList[RetrievingIndexesListIndexInt][1] self.JoinedDeriveDatabaserPointer.retrieve()
def row(self,**_KwargVariablesDict): """Call the Output<HookStr> methods and return self.OutputedPointer (self by default)""" #set the RowedVariablePointer as the NodedDatabaseParentPointer by default if self.RowedVariablePointer==None and hasattr(self,'NodedDatabaseParentPointer'): self.RowedVariablePointer=self.NodedDatabaseParentPointer #Split the GettingStrs between the ones that identify and the other that not self.RowedNotIdentifiedGettingStrsList=filter( lambda __GettingStr: __GettingStr not in self.RowedIdentifiedGettingStrsList, SYS.unzip( self.ModelingDescriptionTuplesList,[0] ) ) self.RowedIdentifiedOrderedDict.update( zip( self.RowedIdentifiedGettingStrsList, self.RowedVariablePointer.pick(self.RowedIdentifiedGettingStrsList) ) ) self.RowedNotIdentifiedOrderedDict.update( zip( self.RowedNotIdentifiedGettingStrsList, self.RowedVariablePointer.pick(self.RowedNotIdentifiedGettingStrsList) ) ) #<NotHook> #table then self.table() #</NotHook> #<NotHook> #Return self return self
def propertize_setModelingDescriptionTuplesList(self,_SettingValueVariable): #set self._ModelingDescriptionTuplesList=_SettingValueVariable #check if self.ModelKeyStrsList==None: self.ModelKeyStrsList=[] #extend self.ModelKeyStrsList.extend( SYS.unzip( _SettingValueVariable, [0] ) ) #/###################/# # Check if it is a hdf or mongo model # #debug ''' self.debug( [ ('self.',self,['ModelingDescriptionTuplesList']) ] ) ''' #Check if len(self.ModelingDescriptionTuplesList)>0: self.ModelingHdfBool=True self.ModelingMongoBool=False else: self.ModelingHdfBool=False self.ModelingMongoBool=True
def do_brian(self): #network first self.network( **{ 'RecruitingConcludeConditionVariable':[ ( '__class__.__mro__', operator.contains,Populater.PopulaterClass ) ] } ) """ #populate map( lambda __NetworkedDeriveConnecter: __NetworkedDeriveConnecter.populate(), self.NetworkedDeriveConnectersList ) """ #set the different times self.BrianedStepTimeFloatsList=list( set( SYS.flat( map( lambda __BrianingDerivePopulater: SYS.unzip( __BrianingDerivePopulater.MoniteringStateTuplesList, [2] ) if len( __BrianingDerivePopulater.MoniteringStateTuplesList )>0 else [], self.NetworkedDeriveConnectersList ) ) ) ) #debug ''' self.debug(('self.',self,['BrianedStepTimeFloatsList'])) ''' #import import brian #Check if self.BrianingTimeDimensionVariable==None: self.BrianingTimeDimensionVariable=brian.ms #init self.BrianedNetworkVariable=brian.MagicNetwork() #set the clocks self.BrianedSimulationClock=brian.Clock( dt=self.SimulatingStepTimeFloat*self.BrianingTimeDimensionVariable ) self.BrianedClocksDict=dict( map( lambda __BrianedStepTimeFloat: ( str(__BrianedStepTimeFloat), brian.Clock( dt=__BrianedStepTimeFloat*self.BrianingTimeDimensionVariable ) ), self.BrianedStepTimeFloatsList ) ,**{ str( self.SimulatingStepTimeFloat ):self.BrianedSimulationClock } ) #debug self.debug(('self.',self,['BrianedClocksDict'])) #set clock to the neuron groups self.BrianedNeuronGroupsList=map( lambda __BrianingDerivePopulater: __BrianingDerivePopulater.__setitem__( 'NeuronGroup', brian.NeuronGroup( __BrianingDerivePopulater.PopulatingUnitsInt, __BrianingDerivePopulater.PopulatingEquationStr, clock=self.BrianedClocksDict[str(self.SimulatingStepTimeFloat)] ) ).NeuronGroup, self.NetworkedDeriveConnectersList ) #set the clocks and state monitors self.BrianedStateMonitorsList=SYS.flat( map( lambda __BrianingDerivePopulater: map( lambda __MoniteringStateTuple: __BrianingDerivePopulater.__setitem__( str(__MoniteringStateTuple)+'StateMonitor', getattr( brian, 'StateMonitor' )( __BrianingDerivePopulater.NeuronGroup, __MoniteringStateTuple[0], record=__MoniteringStateTuple[1], clock=self.BrianedClocksDict[str(__MoniteringStateTuple[2])] ) ).SettingValueVariable, __BrianingDerivePopulater.MoniteringStateTuplesList ), self.NetworkedDeriveConnectersList ) ) #set the spike monitors self.BrianedSpikeMonitorsList=SYS.flat( map( lambda __BrianingDerivePopulater: map( lambda __MoniteringSpikeTuple: __BrianingDerivePopulater.__setitem__( str(__MoniteringSpikeTuple)+'SpikeMonitor', getattr( brian, 'SpikeMonitor' )( __BrianingDerivePopulater.NeuronGroup, ) ).SettingValueVariable, __BrianingDerivePopulater.MoniteringSpikeTuplesList ), self.NetworkedDeriveConnectersList ) ) #set the post synapses self.BrianedSpikeMonitorsList=SYS.flat( map( lambda __BrianingDerivePopulater: map( lambda __MoniteringSpikeTuple: __BrianingDerivePopulater.__setitem__( str(__MoniteringSpikeTuple)+'SpikeMonitor', getattr( brian, 'SpikeMonitor' )( __BrianingDerivePopulater.NeuronGroup, ) ).SettingValueVariable, __BrianingDerivePopulater.MoniteringSpikeTuplesList ), self.NetworkedDeriveConnectersList ) ) #debug ''' self.debug(('self.',self,['NetworkedConnectionTuplesList'])) ''' ''' #set connections self.BrianedConnectionsList=map( lambda __ConnectionTuple: map( lambda __ListedVariable: __ConnectionTuple[0].__setitem__( str( ( __ConnectionTuple[0].NodeKeyStr, __ListedVariable.NodeKeyStr ) )+'Connection', brian.Connection( __ConnectionTuple[0].NeuronGroup, __ListedVariable.NeuronGroup ) ).SettingValueVariable, __ConnectionTuple[1][0] )+map( lambda __ListedVariable: __ListedVariable.__setitem__( str( ( __ListedVariable.NodeKeyStr, __ConnectionTuple[0].NodeKeyStr ) )+'Connection', brian.Connection( __ListedVariable.NeuronGroup, __ConnectionTuple[0].NeuronGroup ) ).SettingValueVariable, __ConnectionTuple[1][1] ), self.NetworkedConnectionTuplesList ) ''' """
def recoverBefore(self,**_LocalRecoveringVariablesDict): #debug print('Joiner recoverBefore method') print('self.RetrievedFilteredRowedDictsList is ') SYS._print(self.RetrievedFilteredRowedDictsList) if hasattr(self,'StructuredKeyStr'): print("self['StructuredKeyStr'] is ",self.StructuredKeyStr) print('') if len(self.RetrievedFilteredRowedDictsList)==1: #debug ''' print('Joiner It is good, there is one solution !') print('') ''' #Definition a JoinedRecoveredDict JoinedRecoveredDict=self.RetrievedFilteredRowedDictsList[0] #debug print('Joiner JoinedRecoveredDict is ') SYS._print(JoinedRecoveredDict) print('self.JoinedNodifiedNodedStr is ',self.JoinedNodifiedNodedStr) if hasattr(self,'StructuredKeyStr'): print("self['StructuredKeyStr'] is ",self.StructuredKeyStr) print('') #Maybe we have to recover the children before ChildJoinersList=self.JoinedNodifiedOrderedDict.values() if len(ChildJoinersList)>0: #set each Children and recover each JoinedNodifiedKeyStr=self.JoinedNodifiedNodedStr+'KeyStr' #debug print('We are going to make recover each children before') if hasattr(self,'StructuredKeyStr'): print('self.StructuredKeyStr is ',self.StructuredKeyStr) print('') print('self.JoinedNodifiedOrderedDict.values() is ',self.JoinedNodifiedOrderedDict.values()) print('') #Map a Recover map( lambda __JoinedJoiner: __JoinedJoiner.__setitem__( '/App_Model_'+self.ModeledDict['ModelingStr']+'Dict/RetrievingIndexesListsList', [ ( JoinStr+self.JoinedJoinedListKeyStr, ( SYS.getIsEqualBool, JoinedRecoveredDict[ self.JoinedNodifiedNodedStr+getattr( __JoinedJoiner, JoinedNodifiedKeyStr )+self.JoinedJoinedListKeyStr ] ) ) ] ).recover(self.ModeledKeyStr), ChildJoinersList ) #Definition the AppendingGettingStrsList=SYS.unzip(self.JoinedFilteredMergedRowedDictsListTuplesList,[0]) #debug print('Joiner maybe update first the joined model') print('self.JoinedFilteredMergedRowedDictsListTuplesList is') SYS._print(self.JoinedFilteredMergedRowedDictsListTuplesList) print('AppendingGettingStrsList is ',AppendingGettingStrsList) #Next we have maybe to update with the joined model if '/' in AppendingGettingStrsList: #Definition the IndexInt of the joined model IndexInt=AppendingGettingStrsList.index('/') #Definition the JoinedFilteredMergedRowedDictsList JoinedFilteredMergedRowedDictsList=self.JoinedFilteredMergedRowedDictsListTuplesList[ IndexInt][1] #Definition the JoinedJoinedList JoinedJoinedList=JoinedRecoveredDict[self.JoinedJoinedListKeyStr] #debug print('JoinedFilteredMergedRowedDictsList is ') SYS._print(JoinedFilteredMergedRowedDictsList) print('JoinedJoinedList is ',JoinedJoinedList) if hasattr(self,'StructuredKeyStr'): print("self['StructuredKeyStr'] is ",self.StructuredKeyStr) print('') #Take the first element of self.JoinedFilteredMergedRowedDictsTuplesList which corresponds to the Joined Model at this level JoinedRowedDict=next( RowedDict for RowedDict in JoinedFilteredMergedRowedDictsList if SYS.getIsEqualBool( RowedDict[self.JoinedJoinedListKeyStr], JoinedJoinedList ) ) #debug ''' print('JoinedRowedDict is ',JoinedRowedDict) print('') ''' #Update self.update(JoinedRowedDict.items()) else: #debug print('Joiner There are multiple retrieved states') if hasattr(self,'StructuredKeyStr'): print("self['StructuredKeyStr'] is ",self.StructuredKeyStr) print('self.RetrievedFilteredRowedDictsList is ') SYS._print(self.RetrievedFilteredRowedDictsList) print('') #Stop the recover self.IsRecoveringBool=False
def rowAfter(self,**_RowingVariablesList): #debug self.debug('Start of the method') #debug self.debug('Look if we have to make row first the noded children') #IsNodingInsertingBool if 'IsNodingRowingBool' not in _InsertingVariablesList or _InsertingVariablesList['IsNodingInsertingBool']: #debug self.debug( [ 'We are going to make row all the joined noded children', 'ModelStr is '+str(ModelStr) ] ) #Row each noded children map( lambda __Variable: __Variable.row(ModelStr), self.ModeledDict['JoinedNodifiedOrderedDict'].values() ) #debug self.debug( [ 'The noded children have inserted' ] ) #debug self.debug( [ "self.ModeledDict['ModelStr'] is "+str(self.ModeledDict['ModelStr']) "We are going to check if the joined model is already inserted...", "First look if JoinedModeledDict!={} is "+str(len(JoinedModeledDict)>0) ] ) #Alias JoinedModeledDict=self.ModeledDict['JoinedModeledDict'] #Check if len(JoinedModeledDict)>0: #debug self.debug("Ok there is some not empty JoinedModeledDict here") #set JoinedRetrievingIndexesListKeyStr JoinedRetrievingIndexesListKeyStr=self.ModeledDict['JoinedRetrievingIndexesListKeyStr'] #Definition the GettingStrsList and the GettedVariablesList if 'ColumningTuplesList' in JoinedModeledDict: #debug self.debug('Check that this joined row is a new row in the table or not') #Get the GettingStrsList and GettedVariablesList GettingStrsList=SYS.unzip(JoinedModeledDict['ColumningTuplesList'],[0]) GettedVariablesList=self.pick(GettingStrsList) #Check if it was already rowed IsRowedBoolsList=map( lambda __Row: all( map( lambda __GettingStr,__GettedVariable: SYS.getIsEqualBool(__Row[__GettingStr],__GettedVariable), GettingStrsList, GettedVariablesList ) ), JoinedModeledDict['TabledTable'].iterrows() ) #debug self.debug( [ 'self.StructuredKeyStr is '+str( self.StructuredKeyStr) if hasattr(self,'StructuredKeyStr') else "", 'IsRowedBoolsList is '+str(IsRowedBoolsList) ] ) #If it is rowed then set the JoinedRetrievingIndexesList try: RowInt=IsRowedBoolsList.index(True) except ValueError: RowInt=-1 #debug self.debug('So the corresponding RowInt is '+str(RowInt)) #set the RowInt self.ModeledDict['JoinedOrderedDict'][JoinedRetrievingIndexesListKeyStr][1]=RowInt #Alias JoinedOrderedDict=self.ModeledDict['JoinedOrderedDict'] JoinedRetrievingIndexesList=self.ModeledDict['JoinedOrderedDict'][JoinedRetrievingIndexesListKeyStr] JoinedNodifiedNodeStr=self.ModeledDict['JoinedNodifiedNodeStr'] JoinedNodifiedNodedStr=self.ModeledDict['JoinedNodifiedNodedStr'] #Give the JoinedRetrievingIndexesList to itself JoinedOrderedDict.__setitem__( JoinedRetrievingIndexesListKeyStr, JoinedRetrievingIndexesList ) #debug self.debug( [ 'JoinedOrderedDict is now', SYS.represent(JoinedOrderedDict) ] ) #Give to the parent if JoinedNodifiedNodeStr!="": ParentPointer=getattr( self, JoinedNodifiedNodedStr+'ParentPointer' ) if ParentPointer!=None: ParentPointer['App_Model_'+ModelingStr+'Dict']['JoinedOrderedDict'][ getattr( self, JoinedNodifiedNodedStr+'KeyStr' )+JoinedRetrievingIndexesListKeyStr ]=JoinedRetrievingIndexesList #Update the self.RowedIdentifiedOrderedDic self.ModeledDict['RowedIdentifiedOrderedDict'].update(JoinedOrderedDict) #debug self.debug('End of the method')
def hopfNetwork(self): #set self.StationarizingPopulationTagVariable=["Agent"] #/###################/# # Check for Populations # #get HopfedPopulationsDeriveManager=self.getTeamer( "Populations" ) #debug ''' self.debug( [ 'We hopf network here', 'Check for an Agent population' ] ) ''' #/###################/# # Check for Agent # #get self.HopfedAgentDeriveHopferVariable=HopfedPopulationsDeriveManager.getManager( self.StationarizingPopulationTagVariable[0] ) #/###############/# # Build the laterals # #type HopfedLateralType=type(self.HopfingLateralWeightVariable) #Check if HopfedLateralType==None.__class__: #debug ''' self.debug( [ 'Ok we build the laterals' ] ) ''' #import import numpy as np #numscipy self.NumscipyingRowsInt=self.HopfingUnitsInt self.NumscipyingColsInt=self.HopfingUnitsInt self.NumscipyingStdFloat=self.HopfingStdWeightFloat/np.sqrt( self.HopfingUnitsInt ) self.NumscipyingMeanFloat=self.HopfingMeanWeightFloat/self.HopfingUnitsInt self.NumscipyingSymmetryFloat=self.HopfingSymmetryFloat self.NumscipyingEigenvalueBool=False self.NumscipyingMeanForceStr="rows" self.NumscipyingSparseFloat=self.HopfingSparseWeightFloat self.NumscipyingSwitchFloat=self.HopfingSwitchWeightFloat #numscipy self.numscipy( ) #alias if self.HopfingInteractionStr=="Rate": self.HopfedLateralWeightFloatsArray = self.HopfingConstantTimeVariable*self.NumscipiedValueFloatsArray else: self.HopfedLateralWeightFloatsArray = 1.*self.NumscipiedValueFloatsArray #debug self.debug( [ "Ok the Js are ", ('self.',self,[ 'HopfedLateralWeightFloatsArray' ]) ] ) #Check if self.HopfingInteractionStr=="Spike": #debug ''' self.debug( [ "We have to modify the matrix G", "First we compute the stationary solution" ] ) ''' #/###################/# # Determine the stationary solutions # #Check if self.HopfingStationaryRateVariable!=None: #set self.HopfedInternalNoiseFloat=np.sqrt( self.HopfingStationaryRateVariable*self.HopfingConstantTimeVariable #)*self.NumscipyingStdFloat )*self.HopfingStdWeightFloat #set self.HopfedStationaryNoiseFloat=np.sqrt( self.HopfedInternalNoiseFloat**2 + self.HopfingStationaryExternalNoiseFloat**2 ) #debug ''' self.debug( [ "We compute the stationary rest external current", ('self.',self,[ 'HopfingStationaryRateVariable', 'HopfedInternalNoiseFloat', 'HopfingStationaryExternalNoiseFloat', 'HopfedStationaryNoiseFloat' ]) ] ) ''' #stationarize self.stationarize( _RateVariable=[self.HopfingStationaryRateVariable], _ConstantTimeVariable=[self.HopfingConstantTimeVariable], _NoiseVariable=[self.HopfedStationaryNoiseFloat], _InteractionStr="Spike" ) #set self.HopfedStationaryExternalCurrentFloat = self.HopfedAgentDeriveHopferVariable.LifedStationaryCurrentFloat+self.HopfingConstantTimeVariable*self.HopfingUnitsInt*self.HopfingMeanWeightFloat*self.HopfingStationaryRateVariable else: #set self.HopfedStationaryExternalCurrentFloat = self.HopfingStationaryExternalMeanVariable #stationarize self.stationarize( _ConstantTimeVariable=[self.HopfingConstantTimeVariable], _ExternalCurrentMeanVariable=[self.HopfingStationaryExternalMeanVariable], _NoiseWeightVariable=[[self.HopfingStdWeightFloat]], _InteractionStr="Spike" ) #set HopfedStationaryRateFloatsArray=np.array( map( lambda __StationarizedRateFloatsArray: __StationarizedRateFloatsArray[0], self.StationarizedRateFloatsArraysList ) ) #get HopfedRateIndexInt=HopfedStationaryRateFloatsArray.argmax() #set self.HopfedStationaryRateFloat=HopfedStationaryRateFloatsArray[HopfedRateIndexInt] #debug ''' self.debug( [ 'HopfedRateIndexInt is '+str(HopfedRateIndexInt), ('self.',self,[ 'StationarizedTotalCurrentMeanFloatsListsList', 'StationarizedRateFloatsArraysList' ]), "HopfedStationaryRateFloatsArray is "+str(HopfedStationaryRateFloatsArray) ] ) ''' #set self.HopfedStationaryMeanFloat=self.StationarizedTotalCurrentMeanFloatsListsList[HopfedRateIndexInt][0] self.HopfedStationaryNoiseFloat=self.StationarizedTotalCurrentNoiseFloatsListsList[HopfedRateIndexInt][0] #debug ''' self.debug( [ ('self.',self,[ 'StationarizedRateFloatsArraysList', 'HopfedStationaryRateFloat' ]) ] ) ''' #debug self.debug( [ "We have computed the rest external current", ('self.',self,[ 'HopfedStationaryMeanFloat', 'HopfedStationaryNoiseFloat', 'HopfedStationaryRateFloat' ] ) ] ) #/###################/# # Determine the null perturbations # #debug ''' self.debug( [ "We compute then the null perturbation ", ] ) ''' #lif self.HopfedAgentDeriveHopferVariable.lif( _StationaryExternalCurrentMeanFloat = self.HopfedStationaryMeanFloat, _StationaryExternalCurrentNoiseFloat = self.HopfedStationaryNoiseFloat, _MeanToRateBool = True, _PerturbationLambdaVariable = 0., _ComputeStationaryBool = True, _ComputePerturbationBool = True, _ComputeNoisePerturbationBool = True ) #debug ''' self.debug( [ "We have lifed", ('self.',self,[ 'LifedPerturbationMeanNullFloat', 'LifedPerturbationStdNullFloat', ]) ] ) ''' #set self.HopfedPerturbationNullFloatsArray = self.HopfingConstantTimeVariable*self.HopfedAgentDeriveHopferVariable.LifedPerturbationMeanNullFloat*self.HopfedLateralWeightFloatsArray[:,:] #self.HopfedPerturbationNullFloatsArray+=( # self.HopfedAgentDeriveHopferVariable.LifedPerturbationNoiseNullFloat/( # 2.*self.HopfedAgentDeriveHopferVariable.LifingNoiseFloat #) #)*(self.HopfedLateralWeightFloatsArray**2) else: #set self.HopfedPerturbationNullFloatsArray = self.HopfedLateralWeightFloatsArray[:,:] #/##############/# # Compute the eigenvalues for the lateral and the null perturb matrix # #import import numpy as np #eigenvalues self.HopfedPerturbationComplexesArray = np.linalg.eigvals( self.HopfedPerturbationNullFloatsArray ) #debug ''' self.debug( [ "We have computed the eigenvalues", ('self.',self,[ #'HopfedLateralEigenvalueComplexesArray', 'HopfedPerturbationComplexesArray', ]) ] ) ''' #/##############/# # Look the shape of the meanfield # #else: # #alias # self.HopfedLateralEigenvalueComplexesArray = self.NumscipiedEigenvalueComplexesArray #set self.HopfedMeanfieldWeightFloat = self.HopfingStdWeightFloat if self.HopfingStdWeightFloat>0. else self.HopfingMeanWeightFloat #debug ''' self.debug( [ 'We have setted the laterals', ('self.',self,[ 'HopfedLateralWeightFloatsArray', 'HopfedMeanfieldWeightFloat' ]) ] ) ''' #Check if self.HopfedMeanfieldWeightFloat==0.: #return self.HopfedIsStableBool=True #return return self #/###############/# # Determine the contour properties # #debug ''' self.debug( [ 'We set the contour of the ellipse', ('self.',self,[ 'NumscipiedVarianceFloat', 'NumscipiedStdFloat', 'NumscipiedCovarianceFloat', 'NumscipiedSommersFloat' ]) ] ) ''' #/###############/# # Build the eigen values real and imag # #import import numpy as np #real and imag self.HopfedPerturbationRealFloatsArray = np.real( self.HopfedPerturbationComplexesArray ) self.HopfedPerturbationImagFloatsArray = np.imag( self.HopfedPerturbationComplexesArray ) #debug ''' self.debug( [ 'We have built the real and imag', ('self.',self,[ 'HopfedRealLateralEigenFloatsArray', 'HopfedImagLateralEigenFloatsArray', 'HopfedPerturbationRealFloatsArray', 'HopfedPerturbationImagFloatsArray' ]) ] ) ''' #/###############/# # Compute for each eigenvalues of J a possible solution # #Check if self.HopfingPerturbationAllBool: #set if self.HopfingInteractionStr == "Rate": self.HopfedInstabilityComplexesArray = 1. * self.HopfedLateralWeightFloatsArray else: self.HopfedInstabilityComplexesArray = self.HopfingConstantTimeVariable * self.HopfedLateralWeightFloatsArray #self.HopfedInstabilityComplexesArray = 1. * self.HopfedLateralWeightFloatsArray #set self.HopfedAgentDeriveHopferVariable.LifingComputeStationaryBool = False self.HopfedAgentDeriveHopferVariable.LifingComputePerturbationBool = True #import import scipy.optimize self.optimize=scipy.optimize #map ''' HopfedSolutionFloatsTuplesList=SYS.filterNone( map( lambda __OptimizeRoot: __OptimizeRoot.x if __OptimizeRoot.success and np.sum(__OptimizeRoot.fun**2)<0.001 else None, map( lambda __HopfedPerturbationComplex: self.setAttr( 'HopfedEigenComplex', __HopfedPerturbationComplex ).optimize.root( getattr( self, 'get'+self.HopfingInteractionStr+'PerturbationSolutionFloatsTuple' ), (-1.,2.*np.pi*100.) ), #self.HopfedPerturbationComplexesArray np.linalg.eigvals( self.HopfedInstabilityComplexesArray ) ) ) ) ''' #set HopfedEigenComplexesArray=np.linalg.eigvals( self.HopfedInstabilityComplexesArray ) #debug ''' self.debug( [ "self.HopfedAgentDeriveHopferVariable.LifedPerturbationMeanNullFloat is "+str(self.HopfedAgentDeriveHopferVariable.LifedPerturbationMeanNullFloat), '1000.*HopfedEigenComplexesArray is '+str( self.HopfedAgentDeriveHopferVariable.LifedPerturbationMeanNullFloat*HopfedEigenComplexesArray #/(self.HopfingConstantTimeVariable*self.HopfedAgentDeriveHopferVariable.LifedPerturbationMeanNullFloat) ) ] ) ''' #map HopfedSolutionFloatsTuplesList=map( lambda __HopfedPerturbationComplex: sorted( map( lambda __PerturbationTuple: self.setAttr( 'HopfedEigenComplex', __HopfedPerturbationComplex ).optimize.fsolve( getattr( self, 'get'+self.HopfingInteractionStr+'PerturbationSolutionFloatsTuple' ), #(0.,0.) #(-1.+__HopfedPerturbationComplex.real,__HopfedPerturbationComplex.imag) __PerturbationTuple ), #[0.01,0.1,10.] #[10.] #[ # #(0.,1.), # (-100.,10.), # #(-200.,1.) #], #[ # # 1000.*np.array([ # -1.+__HopfedPerturbationComplex.real, # __HopfedPerturbationComplex.imag # ] # ) # #/(self.HopfingConstantTimeVariable*self.HopfedAgentDeriveHopferVariable.LifedPerturbationMeanNullFloat) # #] ), key = lambda __ComplexTuple:__ComplexTuple[0] )[-1], #self.HopfedPerturbationComplexesArray HopfedEigenComplexesArray ) #debug ''' self.debug( [ "HopfedSolutionFloatsTuplesList is "+str(HopfedSolutionFloatsTuplesList) ] ) ''' #unpack [ HopfedSolutionRealFloatsTuple, HopfedSolutionImagFloatsTuple ]=SYS.unzip( HopfedSolutionFloatsTuplesList, [0,1] ) self.HopfedSolutionRealFloatsArray=np.array( HopfedSolutionRealFloatsTuple ) self.HopfedSolutionImagFloatsArray=np.array( HopfedSolutionImagFloatsTuple ) #/###############/# # Determine the number of instable eigens # #debug ''' self.debug( [ ('self.',self,[ 'HopfingDoStabilityBool', 'HopfedSolutionRealFloatsArray', ]) ] ) ''' #get self.HopfedInstabilityIndexInt = np.argmax( self.HopfedSolutionRealFloatsArray ) #find InstableEigenIndexIntsArray=np.where( self.HopfedSolutionRealFloatsArray>0. )[0] #debug ''' self.debug( [ "InstableEigenIndexIntsArray is ",str(InstableEigenIndexIntsArray) ] ) ''' #len self.HopfedInstablesInt=len(InstableEigenIndexIntsArray) #Check if self.HopfingCriticalBool: #print ''' self.debug( [ "In the end", ('self.',self,[ 'HopfedInstablesInt', 'HopfingCountInt' ]) ] ) ''' #loop if self.HopfedInstablesInt!=2 and self.HopfingCountInt<10: self.HopfingCountInt+=1 self.hopf( _StdWeightFloat=self.HopfingStdWeightFloat-5.+10.*SYS.scipy.stats.uniform.rvs(size=1) ) return #print ''' self.debug( [ "In the end", ('self.',self,[ 'HopfedInstablesInt' ]) ] ) ''' #/###############/# # Build the contour of the ellipse J eigen values real and ima # #debug ''' self.debug( [ "We build the contours", ('self.',self,[ 'HopfingConstantTimeVariable', 'NumscipiedSommersFloat', 'NumscipyingStdFloat' ]) ] ) ''' #set HopfedSommerFloat=self.NumscipiedSommersFloat #list self.HopfedContourPerturbationComplexesArray=[ __Float + ( 1.-HopfedSommerFloat )*np.sqrt( 1.-(__Float/(1.+HopfedSommerFloat))**2 )*1j for __Float in np.linspace( -1.-HopfedSommerFloat, 1.+HopfedSommerFloat, self.HopfingContourSamplesInt ) ] #list self.HopfedContourPerturbationComplexesArray+=list( np.array( self.HopfedContourPerturbationComplexesArray ).conjugate()[::-1] ) #array self.HopfedContourPerturbationComplexesArray=np.array( self.HopfedContourPerturbationComplexesArray ) #debug ''' self.debug( [ "We normalize the contour with the sdt", ('self.',self,[ 'NumscipyingStdFloat', 'HopfingStdWeightFloat' ]) ] ) ''' #Check if self.HopfingStdWeightFloat>0.: #set self.HopfedContourPerturbationComplexesArray *= self.HopfingStdWeightFloat else: #sqrt self.HopfedStdSparseFloat=np.sqrt( self.NumscipyingSparseFloat*(1.-self.NumscipyingSparseFloat) ) #set self.HopfedContourPerturbationComplexesArray *= self.HopfedStdSparseFloat #Check if self.HopfingInteractionStr == "Rate": #set self.HopfedContourPerturbationComplexesArray *= self.HopfingConstantTimeVariable else: #set self.HopfedContourPerturbationComplexesArray *= self.HopfingConstantTimeVariable*self.HopfedAgentDeriveHopferVariable.LifedPerturbationMeanNullFloat #real and imag self.HopfedContourPerturbationRealFloatsArray=np.real( self.HopfedContourPerturbationComplexesArray ) self.HopfedContourPerturbationImagFloatsArray=np.imag( self.HopfedContourPerturbationComplexesArray ) #/###############/# # Compute for each eigen of the contour a possible solution # #debug ''' self.debug( [ ('self.',self,[ 'HopfingPerturbationEnvelopBool' ]) ] ) ''' #Check if self.HopfingPerturbationEnvelopBool: #Check if self.HopfingInteractionStr == "Spike": HopfedContourInstabilityArray = self.HopfedContourPerturbationComplexesArray/self.HopfedAgentDeriveHopferVariable.LifedPerturbationMeanNullFloat else: HopfedContourInstabilityArray = self.HopfedContourPerturbationComplexesArray #map ''' HopfedContourSolutionFloatsTuplesList=SYS.filterNone( map( lambda __OptimizeRoot: __OptimizeRoot.x if __OptimizeRoot.success and np.sum(__OptimizeRoot.fun**2)<0.001 else None, map( lambda __HopfedContourComplex: self.setAttr( 'HopfedEigenComplex', __HopfedContourComplex ).optimize.root( getattr( self, 'get'+self.HopfingInteractionStr+'PerturbationSolutionFloatsTuple' ), (-0.1,2.*np.pi*10.) ), HopfedContourInstabilityArray #[:2] ) ) ) ''' #map HopfedContourSolutionFloatsTuplesList=map( lambda __HopfedPerturbationComplex: sorted( map( lambda __FrequencyFloat: self.setAttr( 'HopfedEigenComplex', __HopfedPerturbationComplex ).optimize.fsolve( getattr( self, 'get'+self.HopfingInteractionStr+'PerturbationSolutionFloatsTuple' ), #(0.,0.) #(-1.+__HopfedPerturbationComplex.real,__HopfedPerturbationComplex.imag) (0.,2.*np.pi*__FrequencyFloat) ), #[0.1,10.,100.] [10.] if self.HopfingInteractionStr=='Spike' else [0.] ), key = lambda __ComplexTuple:__ComplexTuple[0] )[-1], HopfedContourInstabilityArray ) #unpack [ HopfedContourSolutionRealFloatsTuple, HopfedContourSolutionImagFloatsTuple ]=SYS.unzip( HopfedContourSolutionFloatsTuplesList, [0,1] ) self.HopfedContourSolutionRealFloatsArray=np.array(HopfedContourSolutionRealFloatsTuple) self.HopfedContourSolutionImagFloatsArray=np.array(HopfedContourSolutionImagFloatsTuple) #get self.HopfedInstabilityComplex=self.HopfedSolutionRealFloatsArray[ self.HopfedInstabilityIndexInt ] #set self.HopfedIsStableBool=self.HopfedSolutionRealFloatsArray[ self.HopfedInstabilityIndexInt ]<0. #Check if self.HopfedIsStableBool==False: #set self.HopfedInstabilityStr='Rate' if self.HopfedSolutionImagFloatsArray[ self.HopfedInstabilityIndexInt ]==0. else 'Hopf' #debug ''' self.debug( [ ('self.',self,[ 'HopfedInstabilityIndexInt', 'HopfedInstabilityComplex', 'HopfedIsStableBool', 'HopfedInstabilityStr' ]) ] ) ''' else: pass #debug '''
def do_table(self): # debug """ self.debug(('self.',self,['ModelingDescriptionTuplesList'])) """ # debug """ self.debug( [ 'We are going to look if this is a new table or not...', 'In order to index it', ('self.',self,[ 'ModeledKeyStr', 'ModeledDescriptionClass', ] ) ] ) """ # Check if self.ModelingMongoBool: # debug """ self.debug( 'We tabular mongo here' ) """ # set self.TabledMongoSuffixStr = self.ModelTagStr + "Collection" # debug """ self.debug( [ ('self.',self,[ 'PymongoneClientVariable', 'TabledMongoSuffixStr' ] ) ] ) """ # Check if self.ModelDeriveControllerVariable.PymongoneClientVariable == None: # debug """ self.debug('We have to pymongo first...') """ # pymongo self.ModelDeriveControllerVariable.pymongo() # Link self.TabledMongoTopClientVariable = self.ModelDeriveControllerVariable.PymongoneClientVariable # Check if self.TabledMongoTopClientVariable != None: # debug """ self.debug( [ 'Looking for names of collections here', ('self.',self,[ 'TabledMongoTopClientVariable' ]), ] ) """ # set self.TabledMongoDatabaseKeyStr = self.ModelDeriveControllerVariable.ControlModelStr # set self.ModelDeriveControllerVariable.PymongoingDatabaseKeyStr = self.TabledMongoDatabaseKeyStr # set self.TabledMongoLocalDatabaseVariable = self.TabledMongoTopClientVariable[ self.TabledMongoDatabaseKeyStr ] # debug """ self.debug( [ ('self.',self,[ 'TabledMongoDatabaseKeyStr', 'TabledMongoLocalDatabaseVariable' ]), "id(self.TabledMongoLocalDatabaseVariable) is "+str( id(self.TabledMongoLocalDatabaseVariable)) ] ) """ # set self.TabledMongoLocalDatabaseVariable.__dict__[ "ParentDerivePymongoer" ] = self.ModelDeriveControllerVariable # alias self.ModelDeriveControllerVariable.Database = self.TabledMongoLocalDatabaseVariable # debug """ self.debug( [ ('self.',self,[ 'TabledMongoLocalDatabaseVariable' ]), "'ParentDerivePymongoer' in self.TabledMongoLocalDatabaseVariable.__dict__", 'ParentDerivePymongoer' in self.TabledMongoLocalDatabaseVariable.__dict__ ] ) """ # Get and sort self.TabledMongoKeyStrsList = map( str, sorted( filter( lambda __KeyStr: __KeyStr.endswith(self.TabledMongoSuffixStr), self.TabledMongoLocalDatabaseVariable.collection_names(), ) ), ) # debug """ self.debug( [ ('self.',self,[ 'TabledMongoKeyStrsList' ]) ] ) """ # update self.TabledMongoCollectionsOrderedDict.update( map( lambda __TabledKeyStr: (__TabledKeyStr, self.TabledMongoLocalDatabaseVariable[__TabledKeyStr]), self.TabledMongoKeyStrsList, ) ) # debug """ self.debug(("self.",self,[ 'TabledMongoSuffixStr', 'TabledMongoKeyStrsList' ])) """ # debug """ self.debug( [ 'TabledMongoKeyStrsList', 'TabledMongoSuffixStr', 'TabledMongoKeyStr' ] ) """ # Get the suffix Strs of all the tables and their index TabledMongoList = SYS.unzip( map( lambda __StrsList: (__StrsList[1], TablingOrderStr.join(__StrsList[2:])), map( lambda __TabledMongoKeyStr: __TabledMongoKeyStr.split(TablingOrderStr), self.TabledMongoKeyStrsList, ), ), [0, 1], ) # debug """ self.debug(('vars ',vars(),['TabledHdfList'])) """ # Unpack if it is possible if len(TabledMongoList) > 0: # Unpack [TabledMongoIndexIntsTuple, TabledMongoSuffixStrsList] = TabledMongoList # debug """ self.debug( [ 'There are already some tables', 'TabledMongoSuffixStrsList is '+str(TabledMongoSuffixStrsList), "self.TabledMongoSuffixStr is "+str( self.TabledMongoSuffixStr) ] ) """ if self.TabledMongoSuffixStr not in TabledMongoSuffixStrsList: # Increment the IndexStr TabledMongoIndexInt = max(map(int, TabledMongoIndexIntsTuple)) + 1 # Strify TabledMongoIndexStr = str(TabledMongoIndexInt) # debug """ self.debug('IndexStr of this new table is '+str(IndexStr)) """ else: # Get the already setted one TabledMongoIndexStr = self.TabledMongoKeyStrsList[ TabledMongoSuffixStrsList.index(self.TabledMongoSuffixStr) ].split(TablingOrderStr)[1] # Intify TabledMongoIndexInt = (int)(TabledMongoIndexStr) # debug """ self.debug('IndexStr of this not new table is '+str(IndexStr)) """ else: # debug """ self.debug('There are no tables here') """ # set to empty lists [TabledMongoIndexIntsTuple, TabledMongoSuffixStrsList] = [[], []] # Init the list TabledMongoIndexInt = 0 # Strify TabledMongoIndexStr = "0" # Bind with TabledHdfKeyStr setting self.TabledMongoKeyStr = TablingOrderStr + TabledMongoIndexStr + TablingOrderStr + self.TabledMongoSuffixStr # set the TabledInt self.TabledMongoIndexInt = TabledMongoIndexInt # debug """ self.debug("self.TabledMongoKeyStr is "+str(self.TabledMongoKeyStr)) """ # debug """ self.debug( [ 'Here we create the collection or get it depending if it is new or not', 'self.TabledMongoKeyStr is '+self.TabledMongoKeyStr, 'self.TabledTopFileVariable!=None is '+str(self.TabledTopFileVariable!=None) ] ) """ # Check if self.TabledMongoKeyStr != "" and self.TabledMongoLocalDatabaseVariable != None: # debug """ self.debug( [ ('self.',self,[ 'TabledMongoKeyStr', 'TabledMongoKeyStrsList' ] ), 'self.TabledMongoLocalDatabaseVariable.collection_names() is ', str(self.TabledMongoLocalDatabaseVariable.collection_names()) ] ) """ # Create the collection if not already if self.TabledMongoKeyStr not in self.TabledMongoKeyStrsList: # debug """ self.debug( [ 'The collection not exists', ] ) """ # Create the collections self.TabledMongoCollection = self.TabledMongoLocalDatabaseVariable.create_collection( self.TabledMongoKeyStr ) # Append self.TabledMongoKeyStrsList.append(self.TabledMongoKeyStr) else: # debug """ self.debug( [ 'The collection exists', ] ) """ # Else just get it self.TabledMongoCollection = self.TabledMongoLocalDatabaseVariable[self.TabledMongoKeyStr] # set the in the TabledMongoCollectionsOrderedDict self.TabledMongoCollectionsOrderedDict[self.TabledMongoKeyStr] = self.TabledMongoCollection # debug """ self.debug("self.TabledMongoCollectionsOrderedDict is "+str(self.TabledMongoCollectionsOrderedDict)) """ # debug """ self.debug( [ 'Table is done here for mongo...', ('self.',self,[ 'TabledMongoCollection', 'TabledMongoTopDatabaseVariable' ] ) ] ) """ # Check if self.ModelingHdfBool: # debug """ self.debug('We tabular for hdf here...') """ # set self.TabledHdfSuffixStr = self.ModelTagStr + "Table" # Check if self.ModelDeriveControllerVariable.HdformatedFileVariable == None: # Check if self.ModelDeriveControllerVariable.HdformatingFileKeyStr == "": # set self.ModelDeriveControllerVariable.HdformatingFileKeyStr = ( self.ModelDeriveControllerVariable.ControlModelStr + ".hdf5" ) # debug """ self.debug( [ 'We have to hdformat first...', 'self.ModelDeriveControllerVariable.HdformatingFileKeyStr is ', self.ModelDeriveControllerVariable.HdformatingFileKeyStr ] ) """ # Hdformat self.ModelDeriveControllerVariable.hdformat() # Set self.ModelDeriveControllerVariable.HdfGroupPathStr = self.ModelDeriveControllerVariable.ControlModelStr # Link self.TabledHdfTopFileVariable = self.ModelDeriveControllerVariable.HdformatedFileVariable # debug """ self.debug(('self.',self,[ 'TabledHdfTopFileVariable' ])) """ # /#################/# # Check for all the tables alreday defined here # # Check if self.TabledHdfTopFileVariable != None: # debug """ self.debug( [ 'Looking for names of tables here', ('self.',self,['HdfGroupPathStr']) ] ) """ # Definition Tabled attributes self.TabledHdfGroupVariable = self.TabledHdfTopFileVariable.getNode( self.ModelDeriveControllerVariable.HdfGroupPathStr ) # debug """ self.debug( [ ('looking for tables with the same suffix Str as : '), ('self.',self,['TabledHdfSuffixStr']) ] ) """ # Get and sort self.TabledHdfKeyStrsList = sorted( filter( lambda __KeyStr: __KeyStr.endswith(self.TabledHdfSuffixStr), self.TabledHdfGroupVariable._v_leaves.keys(), ) ) self.TabledHdfTablesOrderedDict.update( map( lambda __TabledKeyStr: ( __TabledKeyStr, self.TabledHdfGroupVariable._f_getChild(__TabledKeyStr), ), self.TabledHdfKeyStrsList, ) ) # debug """ self.debug(("self.",self,[ 'TabledHdfSuffixStr', 'TabledHdfKeyStrsList' ])) """ # /################/# # Refind all the names of the tables # # debug """ self.debug( ('self.',self,[ 'TabledHdfKeyStrsList', 'TabledHdfSuffixStr', 'TabledHdfKeyStr' ]) ) """ # Get the suffix Strs of all the tables and their index TabledHdfList = SYS.unzip( map( lambda __StrsList: (__StrsList[1], TablingOrderStr.join(__StrsList[2:])), map(lambda __TabledHdfKeyStr: __TabledHdfKeyStr.split(TablingOrderStr), self.TabledHdfKeyStrsList), ), [0, 1], ) # debug self.debug(("vars ", vars(), ["TabledHdfList"])) # /##################/# # Find if there are already some tables here and deduce the index of the table # # Unpack if it is possible if len(TabledHdfList) > 0: # Unpack [TabledHdfIndexIntsTuple, TabledHdfSuffixStrsList] = TabledHdfList # debug """ self.debug( [ 'There are already some tables', 'TabledHdfSuffixStrsList is '+str(TabledHdfSuffixStrsList), "self.TabledHdfSuffixStr is "+str( self.TabledHdfSuffixStr) ] ) """ if self.TabledHdfSuffixStr not in TabledHdfSuffixStrsList: # Increment the IndexStr TabledHdfIndexInt = max(map(int, TabledHdfIndexIntsTuple)) + 1 # Strify TabledHdfIndexStr = str(TabledHdfIndexInt) # debug """ self.debug('IndexStr of this new table is '+str(IndexStr)) """ else: # Get the already setted one TabledHdfIndexStr = self.TabledHdfKeyStrsList[ TabledHdfSuffixStrsList.index(self.TabledHdfSuffixStr) ].split(TablingOrderStr)[1] # Intify TabledHdfIndexInt = (int)(TabledHdfIndexStr) # debug """ self.debug('IndexStr of this not new table is '+str(IndexStr)) """ else: # debug """ self.debug('There are no tables here') """ # set to empty lists [TabledHdfIndexIntsTuple, TabledHdfSuffixStrsList] = [[], []] # Init the list TabledHdfIndexInt = 0 # Strify TabledHdfIndexStr = "0" # /##################/# # set the table key str # # debug self.debug(["We set the table key str", ("self.", self, ["TabledHdfKeyStr"])]) # Bind with TabledHdfKeyStr setting self.TabledHdfKeyStr = TablingOrderStr + TabledHdfIndexStr + TablingOrderStr + self.TabledHdfSuffixStr # set the TabledInt self.TabledHdfIndexInt = TabledHdfIndexInt # debug """ self.debug("self.TabledHdfKeyStr is "+str(self.TabledHdfKeyStr)) """ # debug """ self.debug( [ 'Here we create the table or get it depending if it is new or not', ('self.',self,[ 'TabledHdfKeyStr', 'TabledHdfTopFileVariable' ]) ] ) """ # Check if self.TabledHdfKeyStr != "" and self.TabledHdfTopFileVariable != None: # debug """ self.debug( [ ('self.',self,[ 'TabledHdfKeyStr', 'TabledHdfKeyStrsList' ]) ] ) """ # Create the Table if not already if self.TabledHdfKeyStr not in self.TabledHdfKeyStrsList: # debug """ self.debug( [ 'The table not exists', ] ) """ # Create the Table in the hdf5 self.TabledHdfTable = self.TabledHdfTopFileVariable.create_table( self.TabledHdfGroupVariable, self.TabledHdfKeyStr, self.ModeledDescriptionClass, self.ModeledDescriptionClass.__doc__ if self.ModeledDescriptionClass.__doc__ != None else "This is the " + self.ModeledDescriptionClass.__name__, ) # Append self.TabledHdfKeyStrsList.append(self.TabledHdfKeyStr) else: # debug """ self.debug( [ 'The table exists', "self.TabledGroupVariable is "+str(self.TabledGroupVariable) ] ) """ # Else just get it self.TabledHdfTable = self.TabledHdfGroupVariable._f_getChild(self.TabledHdfKeyStr) # set the in the TablesOrderedDict self.TabledHdfTablesOrderedDict[self.TabledHdfKeyStr] = self.TabledHdfTable # debug """ self.debug("self.TabledHdfTablesOrderedDict is "+str( self.TabledHdfTablesOrderedDict)) """ # debug """
def do_shape(self): #/################/# # Shaper is going to modify modeling description so keep an old version of this before # #keep a memory if self.ShapingDescriptionVariable==None: self.ShapingDescriptionVariable=copy.copy( self.ModelingDescriptionTuplesList ) else: self.ModelingDescriptionTuplesList=copy.copy(self.ShapingDescriptionVariable) #/################/# # Pick the shape ints and their get key strs # #debug ''' self.debug( [ 'We shape here', ("self.",self,['ShapingDimensionTuplesList']) ] ) ''' #Check if len(self.ShapingDimensionTuplesList)>0: #set [ self.ShapedDescriptionGetKeyStrsList, ShapedDescriptionDimensionGetTuplesList ]=SYS.unzip(self.ShapingDimensionTuplesList,[0,1]) #list self.ShapedDescriptionGetKeyStrsList=list(self.ShapedDescriptionGetKeyStrsList) #debug ''' self.debug( [ 'ShapedDescriptionDimensionGetTuplesList is ', str(ShapedDescriptionDimensionGetTuplesList) ] ) ''' #unzip self.ShapedDescriptionDimensionGetKeyStrsListsList=SYS.unzip( list(ShapedDescriptionDimensionGetTuplesList),[1] ) #debug self.debug( [ ('self.',self,['ShapedDescriptionDimensionGetKeyStrsListsList']) ] ) #get the corresponding real dimensions self.ShapedDescriptionDimensionIntsListsList=map( lambda __ShapedDescriptionDimensionGetKeyStrsList: self.ModelDeriveControllerVariable[Getter.GetMapStr]( *__ShapedDescriptionDimensionGetKeyStrsList ).ItemizedMapValueVariablesList, self.ShapedDescriptionDimensionGetKeyStrsListsList ) #debug ''' self.debug( [ ('self.',self,['ShapedDescriptionDimensionIntsListsList']) ] ) ''' else: #Default self.ShapedDescriptionGetKeyStrsList=[] self.ShapedDimensionGetKeyStrsList=[] self.ShapedDescriptionDimensionGetKeyStrsListsList=[] #debug ''' self.debug( [ ("self.",self,[ 'ShapedDescriptionGetKeyStrsList', 'ShapedDescriptionDimensionGetKeyStrsListsList', 'ShapedDescriptionDimensionIntsListsList' ]) ] ) ''' #/################/# # Find where in the description tuokes list it has to be modified and # #Definition ModeledGetKeyStrsList=SYS.unzip(self.ModelingDescriptionTuplesList,[0]) #set self.ShapedIndexIntsList=map( lambda __ShapedDescriptionGetKeyStr: ModeledGetKeyStrsList.index(__ShapedDescriptionGetKeyStr), self.ShapedDescriptionGetKeyStrsList ) #debug ''' self.debug( [ 'Check if we know already the modeler', 'self.ModelDeriveControllerVariable!=None is '+str( self.ModelDeriveControllerVariable!=None ) ] ) ''' #/################/# # set flat all the get key str for the shaping int # #Check if self.ModelDeriveControllerVariable!=None: #Flat and set self.ShapedDimensionGetKeyStrsList=list( set( SYS.flat( self.ShapedDescriptionDimensionGetKeyStrsListsList ) ) ) #Pick self.ShapedDimensionIntsList=self.ModelDeriveControllerVariable[Getter.GetMapStr ]( *self.ShapedDimensionGetKeyStrsList ).ItemizedMapValueVariablesList else: #Default self.ShapedDimensionIntsList=[] #/################/# # map a join str with this # #debug ''' self.debug(("self.",self,['ShapedDimensionIntsList'])) ''' #Bind with ModeledShapedStr setting self.ShapedStr=ShapeJoiningStr.join( map( lambda __ShapedDescriptionGetKeyStr,__ShapedDimensionVariable: ShapeJoiningStr+str( __ShapedDescriptionGetKeyStr )+ShapeTuplingStr+str( __ShapedDimensionVariable), self.ShapedDimensionGetKeyStrsList, self.ShapedDimensionIntsList ) ) #debug '''
def do_table(self): #debug ''' self.debug(('self.',self,['ModelingDescriptionTuplesList'])) ''' #debug ''' self.debug( [ 'We are going to look if this is a new table or not...', 'In order to index it', ('self.',self,[ 'ModeledKeyStr', 'ModeledDescriptionClass', ] ) ] ) ''' #Check if self.ModelingMongoBool: #debug ''' self.debug( [ 'TabularedMongoKeyStrsList', 'TabularedMongoSuffixStr', 'TabledMongoKeyStr' ] ) ''' #Get the suffix Strs of all the tables and their index TabledMongoList=SYS.unzip(map( lambda __StrsList: ( __StrsList[1], TablingOrderStr.join(__StrsList[2:]) ), map( lambda __TabledMongoKeyStr: __TabledMongoKeyStr.split(TablingOrderStr), self.TabularedMongoKeyStrsList ) ),[0,1] ) #debug ''' self.debug(('vars ',vars(),['TabledHdfList'])) ''' #Unpack if it is possible if len(TabledMongoList)>0: #Unpack [TabledMongoIndexIntsTuple,TabledMongoSuffixStrsList]=TabledMongoList #debug ''' self.debug( [ 'There are already some tables', 'TabledMongoSuffixStrsList is '+str(TabledMongoSuffixStrsList), "self.TabularedMongoSuffixStr is "+str( self.TabularedMongoSuffixStr) ] ) ''' if self.TabularedMongoSuffixStr not in TabledMongoSuffixStrsList: #Increment the IndexStr TabledMongoIndexInt=max(map(int,TabledMongoIndexIntsTuple))+1 #Strify TabledMongoIndexStr=str(TabledMongoIndexInt) #debug ''' self.debug('IndexStr of this new table is '+str(IndexStr)) ''' else: #Get the already setted one TabledMongoIndexStr=self.TabularedMongoKeyStrsList[ TabledMongoSuffixStrsList.index(self.TabularedMongoSuffixStr) ].split(TablingOrderStr)[1] #Intify TabledMongoIndexInt=(int)(TabledMongoIndexStr) #debug ''' self.debug('IndexStr of this not new table is '+str(IndexStr)) ''' else: #debug ''' self.debug('There are no tables here') ''' #set to empty lists [TabledMongoIndexIntsTuple,TabledMongoSuffixStrsList]=[[],[]] #Init the list TabledMongoIndexInt=0 #Strify TabledMongoIndexStr="0" #Bind with TabledHdfKeyStr setting self.TabledMongoKeyStr=TablingOrderStr+TabledMongoIndexStr+TablingOrderStr+self.TabularedMongoSuffixStr #set the TabularedInt self.TabledMongoIndexInt=TabledMongoIndexInt #debug ''' self.debug("self.TabledMongoKeyStr is "+str(self.TabledMongoKeyStr)) ''' #debug ''' self.debug( [ 'Here we create the collection or get it depending if it is new or not', 'self.TabledMongoKeyStr is '+self.TabledMongoKeyStr, 'self.TabularedTopFileVariable!=None is '+str(self.TabularedTopFileVariable!=None) ] ) ''' #Check if self.TabledMongoKeyStr!="" and self.TabularedMongoLocalDatabaseVariable!=None: #debug ''' self.debug( [ ('self.',self,[ 'TabledMongoKeyStr', 'TabularedMongoKeyStrsList' ] ), 'self.TabularedMongoLocalDatabaseVariable.collection_names() is ', str(self.TabularedMongoLocalDatabaseVariable.collection_names()) ] ) ''' #Create the collection if not already if self.TabledMongoKeyStr not in self.TabularedMongoKeyStrsList: #debug ''' self.debug( [ 'The collection not exists', ] ) ''' #Create the collections self.TabledMongoCollection=self.TabularedMongoLocalDatabaseVariable.create_collection( self.TabledMongoKeyStr ) #Append self.TabularedMongoKeyStrsList.append(self.TabledMongoKeyStr) else: #debug ''' self.debug( [ 'The collection exists', ] ) ''' #Else just get it self.TabledMongoCollection=self.TabularedMongoLocalDatabaseVariable[ self.TabledMongoKeyStr ] #set the in the TabularedMongoCollectionsOrderedDict self.TabularedMongoCollectionsOrderedDict[ self.TabledMongoKeyStr ]=self.TabledMongoCollection #debug ''' self.debug("self.TabularedMongoCollectionsOrderedDict is "+str(self.TabularedMongoCollectionsOrderedDict)) ''' #debug ''' self.debug( [ 'Table is done here for mongo...', ('self.',self,[ 'TabledMongoCollection', 'TabularedMongoTopDatabaseVariable' ] ) ] ) ''' #Check if self.ModelingHdfBool: #/################/# # Refind all the names of the tables # #debug ''' self.debug( ('self.',self,[ 'TabularedHdfKeyStrsList', 'TabularedHdfSuffixStr', 'TabledHdfKeyStr' ]) ) ''' #Get the suffix Strs of all the tables and their index TabledHdfList=SYS.unzip(map( lambda __StrsList: ( __StrsList[1], TablingOrderStr.join(__StrsList[2:]) ), map( lambda __TabledHdfKeyStr: __TabledHdfKeyStr.split(TablingOrderStr), self.TabularedHdfKeyStrsList ) ),[0,1] ) #debug self.debug(('vars ',vars(),['TabledHdfList'])) #/##################/# # Find if there are already some tables here and deduce the index of the table # #Unpack if it is possible if len(TabledHdfList)>0: #Unpack [TabledHdfIndexIntsTuple,TabledHdfSuffixStrsList]=TabledHdfList #debug ''' self.debug( [ 'There are already some tables', 'TabledHdfSuffixStrsList is '+str(TabledHdfSuffixStrsList), "self.TabularedHdfSuffixStr is "+str( self.TabularedHdfSuffixStr) ] ) ''' if self.TabularedHdfSuffixStr not in TabledHdfSuffixStrsList: #Increment the IndexStr TabledHdfIndexInt=max(map(int,TabledHdfIndexIntsTuple))+1 #Strify TabledHdfIndexStr=str(TabledHdfIndexInt) #debug ''' self.debug('IndexStr of this new table is '+str(IndexStr)) ''' else: #Get the already setted one TabledHdfIndexStr=self.TabularedHdfKeyStrsList[ TabledHdfSuffixStrsList.index(self.TabularedHdfSuffixStr) ].split(TablingOrderStr)[1] #Intify TabledHdfIndexInt=(int)(TabledHdfIndexStr) #debug ''' self.debug('IndexStr of this not new table is '+str(IndexStr)) ''' else: #debug ''' self.debug('There are no tables here') ''' #set to empty lists [TabledHdfIndexIntsTuple,TabledHdfSuffixStrsList]=[[],[]] #Init the list TabledHdfIndexInt=0 #Strify TabledHdfIndexStr="0" #/##################/# # set the table key str # #debug self.debug( [ 'We set the table key str', ('self.',self,['TabledHdfKeyStr']) ] ) #Bind with TabledHdfKeyStr setting self.TabledHdfKeyStr=TablingOrderStr+TabledHdfIndexStr+TablingOrderStr+self.TabularedHdfSuffixStr #set the TabularedInt self.TabledHdfIndexInt=TabledHdfIndexInt #debug ''' self.debug("self.TabledHdfKeyStr is "+str(self.TabledHdfKeyStr)) ''' #debug ''' self.debug( [ 'Here we create the table or get it depending if it is new or not', ('self.',self,[ 'TabledHdfKeyStr', 'TabularedHdfTopFileVariable' ]) ] ) ''' #Check if self.TabledHdfKeyStr!="" and self.TabularedHdfTopFileVariable!=None: #debug ''' self.debug( [ ('self.',self,[ 'TabledHdfKeyStr', 'TabularedHdfKeyStrsList' ]) ] ) ''' #Create the Table if not already if self.TabledHdfKeyStr not in self.TabularedHdfKeyStrsList: #debug ''' self.debug( [ 'The table not exists', ] ) ''' #Create the Table in the hdf5 self.TabledHdfTable=self.TabularedHdfTopFileVariable.create_table( self.TabularedHdfGroupVariable, self.TabledHdfKeyStr, self.ModeledDescriptionClass, self.ModeledDescriptionClass.__doc__ if self.ModeledDescriptionClass.__doc__!=None else "This is the "+self.ModeledDescriptionClass.__name__ ) #Append self.TabularedHdfKeyStrsList.append( self.TabledHdfKeyStr ) else: #debug ''' self.debug( [ 'The table exists', "self.TabularedGroupVariable is "+str(self.TabularedGroupVariable) ] ) ''' #Else just get it self.TabledHdfTable=self.TabularedHdfGroupVariable._f_getChild( self.TabledHdfKeyStr ) #set the in the TablesOrderedDict self.TabularedHdfTablesOrderedDict[ self.TabledHdfKeyStr ]=self.TabledHdfTable #debug ''' self.debug("self.TabularedHdfTablesOrderedDict is "+str( self.TabularedHdfTablesOrderedDict)) ''' #debug '''
def do_instance(self): """ """ #Check if self.InstancingIsBool: #Init InstancingClass=None #TuplesList Case if SYS.getIsTuplesListBool(self.InstancingVariable): #debug ''' self.debug('This is a tuples list') ''' if self.InstancingClass==None: #debug ''' self.debug('Find the instancing class') ''' #Definition the KeyStrsList KeyStrsList=SYS.unzip(self.InstancingVariable,[0]) try: InstancingClass=self.InstancingVariable[KeyStrsList.index('InstancingClass')][1] except: pass else: InstancingClass=self.InstancingClass #Check if InstancingClass!=None: #Init self.InstancedVariable=InstancingClass() #Map map( lambda __ItemTuple: self.InstancedVariable.__setattr__(*__ItemTuple), self.InstancingVariable ) #debug ''' self.debug(('vars ',vars(),['InstancedVariable'])) ''' elif hasattr(self.InstancingVariable,'items'): #debug ''' self.debug('This is an itemizing thing') ''' if self.InstancingClass==None: #debug ''' self.debug('Find the instancing class') ''' try: InstancingClass=self.InstancingVariable['InstancingClass'] except: pass else: #Definition InstancingClass=self.InstancingClass if InstancingClass!=None: #Init self.InstancedVariable=InstancingClass() #Map map( lambda __ItemTuple: self.InstancedVariable.__setattr__(*__ItemTuple), self.InstancingVariable.items() ) elif hasattr(self.InstancingVariable,'__dict__'): #Check if self.InstancingClass!=None: #Init self.InstancedVariable=self.InstancingClass()
def do_model(self): """ """ #Debug self.debug('model start') #/###################/# # Define the ModeledKeyStr # if self.ModeledDescriptionKeyStr=='': self.ModeledDescriptionKeyStr=self.ModelTagStr #/###################/# # Mongo Case # #Check if self.ModelingMongoBool: #debug ''' self.debug( 'We model mongo here' ) ''' #set self.ModeledMongoSuffixStr=self.ModelTagStr+'Collection' #debug ''' self.debug( [ ('self.',self,[ 'PymongoneClientVariable', 'ModeledMongoSuffixStr' ] ) ] ) ''' #Check if self.ModelDeriveControllerVariable.PymongoneClientVariable==None: #debug ''' self.debug('We have to pymongo first...') ''' #pymongo self.ModelDeriveControllerVariable.pymongo() #Link self.ModeledMongoTopClientVariable=self.ModelDeriveControllerVariable.PymongoneClientVariable #Check if self.ModeledMongoTopClientVariable!=None: #debug ''' self.debug( [ 'Looking for names of collections here', ('self.',self,[ 'ModeledMongoTopClientVariable' ]), ] ) ''' #set self.ModeledMongoDatabaseKeyStr=self.ModelDeriveControllerVariable.ControlModelStr #set self.ModelDeriveControllerVariable.PymongoingDatabaseKeyStr=self.ModeledMongoDatabaseKeyStr #set self.ModeledMongoLocalDatabaseVariable=self.ModeledMongoTopClientVariable[ self.ModeledMongoDatabaseKeyStr ] #debug ''' self.debug( [ ('self.',self,[ 'ModeledMongoDatabaseKeyStr', 'ModeledMongoLocalDatabaseVariable' ]), "id(self.ModeledMongoLocalDatabaseVariable) is "+str( id(self.ModeledMongoLocalDatabaseVariable)) ] ) ''' #set self.ModeledMongoLocalDatabaseVariable.__dict__[ 'ParentDerivePymongoer' ]=self.ModelDeriveControllerVariable #alias self.ModelDeriveControllerVariable.Database=self.ModeledMongoLocalDatabaseVariable #debug ''' self.debug( [ ('self.',self,[ 'ModeledMongoLocalDatabaseVariable' ]), "'ParentDerivePymongoer' in self.ModeledMongoLocalDatabaseVariable.__dict__", 'ParentDerivePymongoer' in self.ModeledMongoLocalDatabaseVariable.__dict__ ] ) ''' #Get and sort self.ModeledMongoKeyStrsList=map( str, sorted( filter( lambda __KeyStr: __KeyStr.endswith( self.ModeledMongoSuffixStr ), self.ModeledMongoLocalDatabaseVariable.collection_names() ) ) ) #debug ''' self.debug( [ ('self.',self,[ 'ModeledMongoKeyStrsList' ]) ] ) ''' #update self.ModeledMongoCollectionsOrderedDict.update( map( lambda __ModeledKeyStr: ( __ModeledKeyStr, self.ModeledMongoLocalDatabaseVariable[ __ModeledKeyStr ] ), self.ModeledMongoKeyStrsList ) ) #debug ''' self.debug(("self.",self,[ 'ModeledMongoSuffixStr', 'ModeledMongoKeyStrsList' ])) ''' #debug ''' self.debug( [ 'ModeledMongoKeyStrsList', 'ModeledMongoSuffixStr', 'ModeledMongoKeyStr' ] ) ''' #Get the suffix Strs of all the tables and their index ModeledMongoList=SYS.unzip(map( lambda __StrsList: ( __StrsList[1], ModelingOrderStr.join(__StrsList[2:]) ), map( lambda __ModeledMongoKeyStr: __ModeledMongoKeyStr.split(ModelingOrderStr), self.ModeledMongoKeyStrsList ) ),[0,1] ) #debug ''' self.debug(('vars ',vars(),['ModeledHdfList'])) ''' #Unpack if it is possible if len(ModeledMongoList)>0: #Unpack [ModeledMongoIndexIntsTuple,ModeledMongoSuffixStrsList]=ModeledMongoList #debug ''' self.debug( [ 'There are already some tables', 'ModeledMongoSuffixStrsList is '+str(ModeledMongoSuffixStrsList), "self.ModeledMongoSuffixStr is "+str( self.ModeledMongoSuffixStr) ] ) ''' if self.ModeledMongoSuffixStr not in ModeledMongoSuffixStrsList: #Increment the IndexStr ModeledMongoIndexInt=max(map(int,ModeledMongoIndexIntsTuple))+1 #Strify ModeledMongoIndexStr=str(ModeledMongoIndexInt) #debug ''' self.debug('IndexStr of this new table is '+str(IndexStr)) ''' else: #Get the already setted one ModeledMongoIndexStr=self.ModeledMongoKeyStrsList[ ModeledMongoSuffixStrsList.index(self.ModeledMongoSuffixStr) ].split(ModelingOrderStr)[1] #Intify ModeledMongoIndexInt=(int)(ModeledMongoIndexStr) #debug ''' self.debug('IndexStr of this not new table is '+str(IndexStr)) ''' else: #debug ''' self.debug('There are no tables here') ''' #set to empty lists [ModeledMongoIndexIntsTuple,ModeledMongoSuffixStrsList]=[[],[]] #Init the list ModeledMongoIndexInt=0 #Strify ModeledMongoIndexStr="0" #Bind with ModeledHdfKeyStr setting self.ModeledMongoKeyStr=ModelingOrderStr+ModeledMongoIndexStr+ModelingOrderStr+self.ModeledMongoSuffixStr #set the ModeledInt self.ModeledMongoIndexInt=ModeledMongoIndexInt #debug ''' self.debug("self.ModeledMongoKeyStr is "+str(self.ModeledMongoKeyStr)) ''' #debug ''' self.debug( [ 'Here we create the collection or get it depending if it is new or not', 'self.ModeledMongoKeyStr is '+self.ModeledMongoKeyStr, 'self.ModeledTopFileVariable!=None is '+str(self.ModeledTopFileVariable!=None) ] ) ''' #Check if self.ModeledMongoKeyStr!="" and self.ModeledMongoLocalDatabaseVariable!=None: #debug ''' self.debug( [ ('self.',self,[ 'ModeledMongoKeyStr', 'ModeledMongoKeyStrsList' ] ), 'self.ModeledMongoLocalDatabaseVariable.collection_names() is ', str(self.ModeledMongoLocalDatabaseVariable.collection_names()) ] ) ''' #Create the collection if not already if self.ModeledMongoKeyStr not in self.ModeledMongoKeyStrsList: #debug ''' self.debug( [ 'The collection not exists', ] ) ''' #Create the collections self.ModeledMongoCollection=self.ModeledMongoLocalDatabaseVariable.create_collection( self.ModeledMongoKeyStr ) #Append self.ModeledMongoKeyStrsList.append(self.ModeledMongoKeyStr) else: #debug ''' self.debug( [ 'The collection exists', ] ) ''' #Else just get it self.ModeledMongoCollection=self.ModeledMongoLocalDatabaseVariable[ self.ModeledMongoKeyStr ] #set the in the ModeledMongoCollectionsOrderedDict self.ModeledMongoCollectionsOrderedDict[ self.ModeledMongoKeyStr ]=self.ModeledMongoCollection #debug ''' self.debug("self.ModeledMongoCollectionsOrderedDict is "+str(self.ModeledMongoCollectionsOrderedDict)) ''' #debug ''' self.debug( [ 'Table is done here for mongo...', ('self.',self,[ 'ModeledMongoCollection', 'ModeledMongoTopDatabaseVariable' ] ) ] ) ''' #/###################/# # Hdf Case # #Check if self.ModelingHdfBool: #/###################/# # Define the Description # #import import tables #Definition the DescriptionClass class DescriptionClass(tables.IsDescription): #Add (just like a unique KEY in mysql...) RowInt=tables.Int64Col() #debug self.debug( [ 'We add descriptions in the description Class', ('self.',self,['ModelingDescriptionTuplesList']) ] ) #set the cols in the ModelClass map( lambda __ModelingColumnTuple: DescriptionClass.columns.__setitem__( __ModelingColumnTuple[1], __ModelingColumnTuple[2] ), self.ModelingDescriptionTuplesList ) #Give a name DescriptionClass.__name__=SYS.getClassStrWithNameStr(self.ModelTagStr) #set the ModelClass if self.ModeledDescriptionClassesOrderedDict==None: self.ModeledDescriptionClassesOrderedDict=collections.OrderedDict() self.ModeledDescriptionClassesOrderedDict[self.ModelTagStr]=DescriptionClass #set the ModeledDescriptionClass self.ModeledDescriptionClass=DescriptionClass #debug ''' self.debug('We tabular for hdf here...') ''' #set self.ModeledHdfSuffixStr=self.ModelTagStr+'Table' #Check if self.ModelDeriveControllerVariable.HdformatedFileVariable==None: #Check if self.ModelDeriveControllerVariable.HdformatingFileKeyStr=='': #set self.ModelDeriveControllerVariable.HdformatingFileKeyStr=self.ModelDeriveControllerVariable.ControlModelStr+'.hdf5' #debug ''' self.debug( [ 'We have to hdformat first...', 'self.ModelDeriveControllerVariable.HdformatingFileKeyStr is ', self.ModelDeriveControllerVariable.HdformatingFileKeyStr ] ) ''' #Hdformat self.ModelDeriveControllerVariable.hdformat() #Set self.ModelDeriveControllerVariable.HdfGroupPathStr=self.ModelDeriveControllerVariable.ControlModelStr #Link self.ModeledHdfTopFileVariable=self.ModelDeriveControllerVariable.HdformatedFileVariable #debug ''' self.debug(('self.',self,[ 'ModeledHdfTopFileVariable' ])) ''' #/#################/# # Check for all the tables alreday defined here # #Check if self.ModeledHdfTopFileVariable!=None: #debug ''' self.debug( [ 'Looking for names of tables here', ('self.',self,['HdfGroupPathStr']) ] ) ''' #Definition Modeled attributes self.ModeledHdfGroupVariable=self.ModeledHdfTopFileVariable.getNode( self.ModelDeriveControllerVariable.HdfGroupPathStr ) #debug ''' self.debug( [ ('looking for tables with the same suffix Str as : '), ('self.',self,['ModeledHdfSuffixStr']) ] ) ''' #Get and sort self.ModeledHdfKeyStrsList=sorted( filter( lambda __KeyStr: __KeyStr.endswith(self.ModeledHdfSuffixStr), self.ModeledHdfGroupVariable._v_leaves.keys() ) ) self.ModeledHdfTablesOrderedDict.update( map( lambda __ModeledKeyStr: ( __ModeledKeyStr, self.ModeledHdfGroupVariable._f_getChild( __ModeledKeyStr ) ), self.ModeledHdfKeyStrsList ) ) #debug ''' self.debug(("self.",self,[ 'ModeledHdfSuffixStr', 'ModeledHdfKeyStrsList' ])) ''' #/################/# # Refind all the names of the tables # #debug ''' self.debug( ('self.',self,[ 'ModeledHdfKeyStrsList', 'ModeledHdfSuffixStr', 'ModeledHdfKeyStr' ]) ) ''' #Get the suffix Strs of all the tables and their index ModeledHdfList=SYS.unzip(map( lambda __StrsList: ( __StrsList[1], ModelingOrderStr.join(__StrsList[2:]) ), map( lambda __ModeledHdfKeyStr: __ModeledHdfKeyStr.split(ModelingOrderStr), self.ModeledHdfKeyStrsList ) ),[0,1] ) #debug self.debug(('vars ',vars(),['ModeledHdfList'])) #/##################/# # Find if there are already some tables here and deduce the index of the table # #Unpack if it is possible if len(ModeledHdfList)>0: #Unpack [ModeledHdfIndexIntsTuple,ModeledHdfSuffixStrsList]=ModeledHdfList #debug ''' self.debug( [ 'There are already some tables', 'ModeledHdfSuffixStrsList is '+str(ModeledHdfSuffixStrsList), "self.ModeledHdfSuffixStr is "+str( self.ModeledHdfSuffixStr) ] ) ''' if self.ModeledHdfSuffixStr not in ModeledHdfSuffixStrsList: #Increment the IndexStr ModeledHdfIndexInt=max(map(int,ModeledHdfIndexIntsTuple))+1 #Strify ModeledHdfIndexStr=str(ModeledHdfIndexInt) #debug ''' self.debug('IndexStr of this new table is '+str(IndexStr)) ''' else: #Get the already setted one ModeledHdfIndexStr=self.ModeledHdfKeyStrsList[ ModeledHdfSuffixStrsList.index(self.ModeledHdfSuffixStr) ].split(ModelingOrderStr)[1] #Intify ModeledHdfIndexInt=(int)(ModeledHdfIndexStr) #debug ''' self.debug('IndexStr of this not new table is '+str(IndexStr)) ''' else: #debug ''' self.debug('There are no tables here') ''' #set to empty lists [ModeledHdfIndexIntsTuple,ModeledHdfSuffixStrsList]=[[],[]] #Init the list ModeledHdfIndexInt=0 #Strify ModeledHdfIndexStr="0" #/##################/# # set the table key str # #debug self.debug( [ 'We set the table key str', ('self.',self,['ModeledHdfKeyStr']) ] ) #Bind with ModeledHdfKeyStr setting self.ModeledHdfKeyStr=ModelingOrderStr+ModeledHdfIndexStr+ModelingOrderStr+self.ModeledHdfSuffixStr #set the ModeledInt self.ModeledHdfIndexInt=ModeledHdfIndexInt #debug ''' self.debug("self.ModeledHdfKeyStr is "+str(self.ModeledHdfKeyStr)) ''' #debug ''' self.debug( [ 'Here we create the table or get it depending if it is new or not', ('self.',self,[ 'ModeledHdfKeyStr', 'ModeledHdfTopFileVariable' ]) ] ) ''' #Check if self.ModeledHdfKeyStr!="" and self.ModeledHdfTopFileVariable!=None: #debug ''' self.debug( [ ('self.',self,[ 'ModeledHdfKeyStr', 'ModeledHdfKeyStrsList' ]) ] ) ''' #Create the Table if not already if self.ModeledHdfKeyStr not in self.ModeledHdfKeyStrsList: #debug ''' self.debug( [ 'The table not exists', ] ) ''' #Create the Table in the hdf5 self.ModeledHdfTable=self.ModeledHdfTopFileVariable.create_table( self.ModeledHdfGroupVariable, self.ModeledHdfKeyStr, self.ModeledDescriptionClass, self.ModeledDescriptionClass.__doc__ if self.ModeledDescriptionClass.__doc__!=None else "This is the "+self.ModeledDescriptionClass.__name__ ) #Append self.ModeledHdfKeyStrsList.append( self.ModeledHdfKeyStr ) else: #debug ''' self.debug( [ 'The table exists', "self.ModeledGroupVariable is "+str(self.ModeledGroupVariable) ] ) ''' #Else just get it self.ModeledHdfTable=self.ModeledHdfGroupVariable._f_getChild( self.ModeledHdfKeyStr ) #set the in the TablesOrderedDict self.ModeledHdfTablesOrderedDict[ self.ModeledHdfKeyStr ]=self.ModeledHdfTable #debug ''' self.debug("self.ModeledHdfTablesOrderedDict is "+str( self.ModeledHdfTablesOrderedDict)) ''' #debug '''
def do_append(self): """ """ #debug ''' self.debug('self.AppendingCollectionVariable is '+str(self.AppendingCollectionVariable)) ''' #TuplesList Case if SYS.getIsTuplesListBool(self.AppendingCollectionVariable): #debug ''' self.debug('This is a tuples list') ''' #Definition the KeyStrsList AppendedKeyStrsList=SYS.unzip(self.AppendingCollectionVariable,[0]) #Look for an AppendingNodeCollectionStr try: NodeCollectionStrIndexInt=AppendedKeyStrsList.index( "NodeCollectionStr" ) self.AppendedNodeCollectionStr=self.AppendingCollectionVariable[ NodeCollectionStrIndexInt ][1] ''' #self.AppendedKeyStrKeyStr='Noded'+self.AppendedNodeCollectionStr+'KeyStr' try: AppendedKeyStrIndexInt=AppendedKeyStrsList.index( self.AppendedKeyStrKeyStr ) self.AppendedKeyStr=self.AppendingCollectionVariable[KeyStrIndexInt][1] except: pass ''' NodeKeyStrIndexInt=AppendedKeyStrsList.index( "NodeKeyStr" ) self.AppendedNodeKeyStr=self.AppendingCollectionVariable[ NodeKeyStrIndexInt ][1] except: pass else: #Objects Case if "AppenderClass" in map( lambda __Class: __Class.__name__, type(self.AppendingCollectionVariable).__mro__ ): #debug ''' self.debug('This is a derived object from an Appender') ''' #set AppendedDict=self.AppendingCollectionVariable.__dict__ #dict Case elif type(self.AppendingCollectionVariable) in [dict,collections.OrderedDict]: AppendedDict=self.AppendingCollectionVariable try: #set self.AppendedNodeCollectionStr=AppendedDict["NodeCollectionStr"] self.AppendedNodeKeyStr=AppendedDict[ 'NodeKeyStr' ] except: pass #Init the SettingVariable and Add the NodifyingStr AppendedSettingKeyVariable=Noder.NodingPrefixGetStr+self.AppendedNodeCollectionStr+Noder.NodingSuffixGetStr+self.AppendedNodeKeyStr #debug self.debug([ ('self.',self,[ 'AppendedNodeCollectionStr', 'AppendedNodeKeyStr' ]) ] ) #Then set if AppendedSettingKeyVariable!=Noder.NodingPrefixGetStr+Noder.NodingSuffixGetStr: self.__setitem__( AppendedSettingKeyVariable, self.AppendingCollectionVariable )
def rowAfter(self,**_RowingVariablesList): #debug self.debug('Start of the method') #debug DebuggingStr="self.ModeledDict['ModelStr'] is "+str(self.ModeledDict['ModelStr']) DebuggingStr+='\nWe are going to check if this model is already inserted...' self.debug(DebuggingStr) #Alias JoinedModeledDict=self.ModeledDict['JoinedModeledDict'] #Check if JoinedModeledDict!={}: #set JoinedRetrievingIndexesListKeyStr JoinedRetrievingIndexesListKeyStr=self.ModeledDict['JoinedRetrievingIndexesListKeyStr'] #Definition the GettingStrsList and the GettedVariablesList if 'ColumningTuplesList' in JoinedModeledDict: #debug self.debug('Check that this row is a new row in the table or not') #Get the GettingStrsList and GettedVariablesList GettingStrsList=SYS.unzip(JoinedModeledDict['ColumningTuplesList'],[0]) GettedVariablesList=self.pick(GettingStrsList) #Check if it was already rowed IsRowedBoolsList=map( lambda __Row: all( map( lambda __GettingStr,__GettedVariable: SYS.getIsEqualBool(__Row[__GettingStr],__GettedVariable), GettingStrsList, GettedVariablesList ) ), JoinedModeledDict['TabularedTable'].iterrows() ) #debug if hasattr(self,'StructuredKeyStr'): self.debug('self.StructuredKeyStr is '+str(self.StructuredKeyStr)) self.debug('IsRowedBoolsList is '+str(IsRowedBoolsList)) #If it is rowed then set the JoinedRetrievingIndexesList try: RowInt=IsRowedBoolsList.index(True) except ValueError: RowInt=-1 #debug self.debug('So the corresponding RowInt is '+str(RowInt)) #set the RowInt self.ModeledDict['JoinedOrderedDict'][JoinedRetrievingIndexesListKeyStr][1]=RowInt #Alias JoinedOrderedDict=self.ModeledDict['JoinedOrderedDict'] JoinedRetrievingIndexesList=self.ModeledDict['JoinedOrderedDict'][JoinedRetrievingIndexesListKeyStr] JoinedNodifiedNodeStr=self.ModeledDict['JoinedNodifiedNodeStr'] #Give the JoinedRetrievingIndexesList to itself JoinedOrderedDict.__setitem__( JoinedRetrievingIndexesListKeyStr, JoinedRetrievingIndexesList ) #debug self.debug( [ 'JoinedOrderedDict is now', SYS.represent(JoinedOrderedDict) ] ) #Give to the parent if JoinedNodifiedNodeStr!="": ParentPointer=getattr( self, JoinedNodifiedNodedStr+'ParentPointer' ) if ParentPointer!=None: ParentPointer['App_Model_'+ModelingStr+'Dict']['JoinedOrderedDict'][ getattr( self, JoinedNodifiedNodedStr+'KeyStr' )+JoinedRetrievingIndexesListKeyStr ]=JoinedRetrievingIndexesList #Update the self.RowedIdentifiedOrderedDic self.ModeledDict['RowedIdentifiedOrderedDict'].update(JoinedOrderedDict) #debug self.debug('End of the method')
def mimic_set(self): #Check if self.SettingKeyVariable in [ FigurePlotKeyStr, FigureScatterKeyStr, FigureBarKeyStr ]: #debug ''' self.debug( [ 'before plot', ('self.',self,[ #'ViewDeriveControllerVariable', 'SettingValueVariable' ]) ] ) ''' #init FigurePlotArgumentDict=Setter.ArgumentDict( self.SettingValueVariable, self.ViewDeriveControllerVariable ) #debug ''' self.debug( [ 'We plot here', 'FigurePlotArgumentDict is', SYS._str(FigurePlotArgumentDict) ] ) ''' #plot self.FigureCartoonVariablesList.append( self.FiguredAxesVariable.plot( *FigurePlotArgumentDict['LiargVariablesList'], **FigurePlotArgumentDict['KwargVariablesDict'] )[0] ) #debug ''' self.debug( [ ('self.',self,['FigureCartoonVariablesList']), #str(self.FigureCartoonVariablesList[0][0]), ] ) ''' #return return {'HookingIsBool':False} elif self.SettingKeyVariable==FigureAxesKeyStr: #debug ''' self.debug( [ 'before axes', ('self.',self,[ #'ViewDeriveControllerVariable', 'FiguredAxesVariable' ]) ] ) ''' #map ArgumentTuplesList=map( lambda __ItemTuple: ( __ItemTuple[0], Setter.ArgumentDict( __ItemTuple[1], self.ViewDeriveControllerVariable ) ), SYS.SetList( self.SettingValueVariable ) ) #/#################/# # Special case for the legend # #dict ArgumentDict=dict(ArgumentTuplesList) if 'legend' in ArgumentDict: """ #Check if '#kwarg' not in ArgumentDict['legend']: ArgumentDict['legend']['#kwarg']={} #add ArgumentDict['legend']['#kwarg']['handles']=SYS.flat( map( lambda __Figurer: __Figurer.FigureCartoonVariablesList, self.TeamDict['Plots'].ManagementDict.values() ) ) """ #legend self.FiguredAxesVariable.legend() #link #ArgumentTuplesList[SYS.unzip(ArgumentTuplesList,[0]).index('legend')]=( # 'legend', # ArgumentDict['legend'] #) #remove del ArgumentTuplesList[SYS.unzip(ArgumentTuplesList,[0]).index('legend')] #debug self.debug( [ 'We axe here', 'ArgumentTuplesList is ', SYS._str(ArgumentTuplesList) ] ) #map map( lambda __ArgumentTuple: getattr( self.FiguredAxesVariable, __ArgumentTuple[0] )() if len(__ArgumentTuple[1]['LiargVariablesList'] )==0 and __ArgumentTuple[1]['KwargVariablesDict']==None else( getattr( self.FiguredAxesVariable, __ArgumentTuple[0], **__ArgumentTuple[1]['KwargVariablesDict'] )() if len(__ArgumentTuple[1]['LiargVariablesList'] )==0 else( getattr( self.FiguredAxesVariable, __ArgumentTuple[0] )( *__ArgumentTuple[1]['LiargVariablesList'], **__ArgumentTuple[1]['KwargVariablesDict'] ) if __ArgumentTuple[1]['KwargVariablesDict']!=None else getattr( self.FiguredAxesVariable, __ArgumentTuple[0] )( *__ArgumentTuple[1]['LiargVariablesList'] ) ) ), ArgumentTuplesList ) #return return {'HookingIsBool':False} elif type(self.SettingKeyVariable)==str and self.SettingKeyVariable.startswith( FigureMpld3KeyStr): #deprefix ToolTipKeyStr=SYS.deprefix( self.SettingKeyVariable, FigureMpld3KeyStr ) #debug ''' self.debug( [ 'before plugins', ('self.',self,['ViewDeriveControllerVariable']) ] ) ''' #init FigurePluginArgumentDict=Setter.ArgumentDict( self.SettingValueVariable, self.ViewDeriveControllerVariable ) #debug ''' self.debug( [ 'We plugin here', 'FigurePluginArgumentDict is ', SYS._str(FigurePluginArgumentDict) ] ) ''' #plugin from mpld3 import plugins self.FigureTooltipVariablesList=map( lambda __FigureCartoonVariable: getattr( plugins, ToolTipKeyStr )( *[ __FigureCartoonVariable ]+FigurePluginArgumentDict['LiargVariablesList'], **FigurePluginArgumentDict['KwargVariablesDict'] ), self.FigureCartoonVariablesList ) #debug ''' self.debug( [ ('self.',self,['FigureTooltipVariablesList']) ] ) ''' #connect map( lambda __FigureTooltipVariable: plugins.connect( self.FigurePyplotVariable, __FigureTooltipVariable ), self.FigureTooltipVariablesList ) #return return {'HookingIsBool':False} #call the base method BaseClass.set(self)
def do_model(self): """ """ # Debug """ self.debug( [ 'model start', ('self.',self,[ 'ModelMongoBool', 'ModelHdfBool' ]) ] ) """ # /###################/# # Mongo Case # # Check if self.ModelMongoBool: # debug """ self.debug( 'We model mongo here' ) """ # set self.ModeledMongoSuffixStr = self.ModelTagStr + "Collection" # debug """ self.debug( [ ('self.',self,[ 'PymongoneClientVariable', 'ModeledMongoSuffixStr' ] ) ] ) """ # Check if self.ModelDeriveControllerVariable.PymongoneClientVariable == None: # debug """ self.debug('We have to pymongo first...') """ # pymongo self.ModelDeriveControllerVariable.pymongo() # Link self.ModeledMongoTopClientVariable = self.ModelDeriveControllerVariable.PymongoneClientVariable # Check if self.ModeledMongoTopClientVariable != None: # debug """ self.debug( [ 'Looking for names of collections here', ('self.',self,[ 'ModeledMongoTopClientVariable' ]), ] ) """ # /#################/# # Check for the name # # Check if self.ModelDeriveControllerVariable.PymongoingDatabaseStr == "": # set self.ModeledMongoDatabaseKeyStr = self.ModelDeriveControllerVariable.ControlTagStr # set self.ModelDeriveControllerVariable.PymongoingDatabaseStr = self.ModeledMongoDatabaseKeyStr else: # set self.ModeledMongoDatabaseKeyStr = self.ModelDeriveControllerVariable.PymongoingDatabaseStr # set self.ModeledMongoLocalDatabaseVariable = self.ModeledMongoTopClientVariable[ self.ModeledMongoDatabaseKeyStr ] # debug """ self.debug( [ ('self.',self,[ 'ModeledMongoDatabaseKeyStr', 'ModeledMongoLocalDatabaseVariable' ]), "id(self.ModeledMongoLocalDatabaseVariable) is "+str( id(self.ModeledMongoLocalDatabaseVariable)) ] ) """ # set self.ModeledMongoLocalDatabaseVariable.__dict__[ "ParentDerivePymongoer" ] = self.ModelDeriveControllerVariable # alias self.ModelDeriveControllerVariable.Database = self.ModeledMongoLocalDatabaseVariable # debug """ self.debug( [ ('self.',self,[ 'ModeledMongoLocalDatabaseVariable' ]), "'ParentDerivePymongoer' in self.ModeledMongoLocalDatabaseVariable.__dict__", 'ParentDerivePymongoer' in self.ModeledMongoLocalDatabaseVariable.__dict__ ] ) """ # Get and sort self.ModeledMongoKeyStrsList = map( str, sorted( filter( lambda __KeyStr: __KeyStr.endswith(self.ModeledMongoSuffixStr), self.ModeledMongoLocalDatabaseVariable.collection_names(), ) ), ) # debug """ self.debug( [ ('self.',self,[ 'ModeledMongoKeyStrsList' ]) ] ) """ # update self.ModeledMongoCollectionsOrderedDict.update( map( lambda __ModeledKeyStr: ( __ModeledKeyStr, self.ModeledMongoLocalDatabaseVariable[__ModeledKeyStr], ), self.ModeledMongoKeyStrsList, ) ) # debug """ self.debug(("self.",self,[ 'ModeledMongoSuffixStr', 'ModeledMongoKeyStrsList' ])) """ # debug """ self.debug( [ 'ModeledMongoKeyStrsList', 'ModeledMongoSuffixStr', 'ModeledMongoKeyStr' ] ) """ # Get the suffix Strs of all the tables and their index ModeledMongoList = SYS.unzip( map( lambda __StrsList: (__StrsList[1], ModelOrderStr.join(__StrsList[2:])), map( lambda __ModeledMongoKeyStr: __ModeledMongoKeyStr.split(ModelOrderStr), self.ModeledMongoKeyStrsList, ), ), [0, 1], ) # debug """ self.debug(('vars ',vars(),['ModeledHdfList'])) """ # Unpack if it is possible if len(ModeledMongoList) > 0: # Unpack [ModeledMongoIndexIntsTuple, ModeledMongoSuffixStrsList] = ModeledMongoList # debug """ self.debug( [ 'There are already some tables', 'ModeledMongoSuffixStrsList is '+str(ModeledMongoSuffixStrsList), "self.ModeledMongoSuffixStr is "+str( self.ModeledMongoSuffixStr) ] ) """ if self.ModeledMongoSuffixStr not in ModeledMongoSuffixStrsList: # Increment the IndexStr ModeledMongoIndexInt = max(map(int, ModeledMongoIndexIntsTuple)) + 1 # Strify ModeledMongoIndexStr = str(ModeledMongoIndexInt) # debug """ self.debug('IndexStr of this new table is '+str(IndexStr)) """ else: # Get the already setted one ModeledMongoIndexStr = self.ModeledMongoKeyStrsList[ ModeledMongoSuffixStrsList.index(self.ModeledMongoSuffixStr) ].split(ModelOrderStr)[1] # Intify ModeledMongoIndexInt = (int)(ModeledMongoIndexStr) # debug """ self.debug('IndexStr of this not new table is '+str(IndexStr)) """ else: # debug """ self.debug('There are no tables here') """ # set to empty lists [ModeledMongoIndexIntsTuple, ModeledMongoSuffixStrsList] = [[], []] # Init the list ModeledMongoIndexInt = 0 # Strify ModeledMongoIndexStr = "0" # Bind with ModeledHdfKeyStr setting self.ModeledMongoKeyStr = ModelOrderStr + ModeledMongoIndexStr + ModelOrderStr + self.ModeledMongoSuffixStr # set the ModeledInt self.ModeledMongoIndexInt = ModeledMongoIndexInt # debug """ self.debug("self.ModeledMongoKeyStr is "+str(self.ModeledMongoKeyStr)) """ # debug """ self.debug( [ 'Here we create the collection or get it depending if it is new or not', 'self.ModeledMongoKeyStr is '+self.ModeledMongoKeyStr, 'self.ModeledTopFileVariable!=None is '+str(self.ModeledTopFileVariable!=None) ] ) """ # Check if self.ModeledMongoKeyStr != "" and self.ModeledMongoLocalDatabaseVariable != None: # debug """ self.debug( [ ('self.',self,[ 'ModeledMongoKeyStr', 'ModeledMongoKeyStrsList' ] ), 'self.ModeledMongoLocalDatabaseVariable.collection_names() is ', str(self.ModeledMongoLocalDatabaseVariable.collection_names()) ] ) """ # Create the collection if not already if self.ModeledMongoKeyStr not in self.ModeledMongoKeyStrsList: # debug """ self.debug( [ 'The collection not exists', ] ) """ # Create the collections self.ModeledMongoCollection = self.ModeledMongoLocalDatabaseVariable.create_collection( self.ModeledMongoKeyStr ) # Append self.ModeledMongoKeyStrsList.append(self.ModeledMongoKeyStr) else: # debug """ self.debug( [ 'The collection exists', ] ) """ # Else just get it self.ModeledMongoCollection = self.ModeledMongoLocalDatabaseVariable[self.ModeledMongoKeyStr] # set the in the ModeledMongoCollectionsOrderedDict self.ModeledMongoCollectionsOrderedDict[self.ModeledMongoKeyStr] = self.ModeledMongoCollection # debug """ self.debug("self.ModeledMongoCollectionsOrderedDict is "+str(self.ModeledMongoCollectionsOrderedDict)) """ # debug """ self.debug( [ 'Table is done here for mongo...', ('self.',self,[ 'ModeledMongoCollection', 'ModeledMongoTopDatabaseVariable' ] ) ] ) """ # /###################/# # Hdf Case # # Check if self.ModelHdfBool: # /################/# # Model is to modify modeling description so keep an old version of this before # # debug """ self.debug( [ 'Keep maybe a copy of ModelingDescriptionTuplesList', ('self.',self,[ 'ModelingDescriptionTuplesList', 'ModelDescriptionTuplesList' ]) ] ) """ # keep a memory if self.ModelDescriptionTuplesList == None: # copy self.ModelDescriptionTuplesList = copy.deepcopy(self.ModelingDescriptionTuplesList) # /################/# # Pick the shape ints and their get key strs # # debug """ self.debug( [ 'We model shape here', ("self.",self,['ModelDimensionTuplesList']) ] ) """ # Check if self.ModelDimensionTuplesList != None and len(self.ModelDimensionTuplesList) > 0: # set [self.ModeledDescriptionGetKeyStrsList, ModeledDescriptionDimensionGetTuplesList] = SYS.unzip( self.ModelDimensionTuplesList, [0, 1] ) # list self.ModeledDescriptionGetKeyStrsList = list(self.ModeledDescriptionGetKeyStrsList) # debug """ self.debug( [ 'ModeledDescriptionDimensionGetTuplesList is ', str(ModeledDescriptionDimensionGetTuplesList) ] ) """ # unzip self.ModeledDescriptionDimensionGetKeyStrsListsList = SYS.unzip( list(ModeledDescriptionDimensionGetTuplesList), [1] ) # debug """ self.debug( [ ('self.',self,['ModeledDescriptionDimensionGetKeyStrsListsList']) ] ) """ # /###################/# # Check the dimension that are not defined or equal to zero # set them to one # map map self.ModeledDescriptionDimensionIntsListsList = map( lambda __ModeledDescriptionDimensionGetKeyStrsList: map( lambda __ModeledDescriptionDimensionGetKeyStr, __ShapeInt: self.ModelDeriveControllerVariable.set( __ModeledDescriptionDimensionGetKeyStr, __ShapeInt + 1 )[ __ModeledDescriptionDimensionGetKeyStr ] if __ShapeInt == 0 else __ShapeInt, __ModeledDescriptionDimensionGetKeyStrsList, map( lambda __ModeledDescriptionDimensionGetKeyStr: self.ModelDeriveControllerVariable[ __ModeledDescriptionDimensionGetKeyStr ], __ModeledDescriptionDimensionGetKeyStrsList, ), ), self.ModeledDescriptionDimensionGetKeyStrsListsList, ) # get the corresponding real dimensions """ self.ModeledDescriptionDimensionIntsListsList=map( lambda __ModeledDescriptionDimensionGetKeyStrsList: self.ModelDeriveControllerVariable[ Getter.GetMapStr ]( *__ModeledDescriptionDimensionGetKeyStrsList ).ItemizedMapValueVariablesList, self.ModeledDescriptionDimensionGetKeyStrsListsList ) """ # debug """ self.debug( [ ('self.',self,[ 'ModeledDescriptionDimensionIntsListsList' ]) ] ) """ else: # Default self.ModeledDescriptionGetKeyStrsList = [] self.ModeledDimensionGetKeyStrsList = [] self.ModeledDescriptionDimensionGetKeyStrsListsList = [] # debug """ self.debug( [ ("self.",self,[ 'ModeledDescriptionGetKeyStrsList', 'ModeledDescriptionDimensionGetKeyStrsListsList', 'ModeledDescriptionDimensionIntsListsList' ]) ] ) """ # /################/# # Find where in the description takes list it has to be modified # # Definition ModeledGetKeyStrsList = SYS.unzip(self.ModelingDescriptionTuplesList, [0]) # set self.ModeledShapeIndexIntsList = map( lambda __ModeledDescriptionGetKeyStr: ModeledGetKeyStrsList.index(__ModeledDescriptionGetKeyStr), self.ModeledDescriptionGetKeyStrsList, ) # debug """ self.debug( [ 'We know the index of the shape description tuples', ('self.',self,['ModeledShapeIndexIntsList']) ] ) """ # /################/# # set flat all the get key str for the shaping int # # Check if self.ModelDeriveControllerVariable != None: # debug """ self.debug( [ 'We flat the DimensionGetKeyStrsLists', ('self.',self,[ 'ModeledDescriptionDimensionGetKeyStrsListsList' ]) ] ) """ # Flat and set self.ModeledDimensionGetKeyStrsList = list( set(SYS.flat(self.ModeledDescriptionDimensionGetKeyStrsListsList)) ) # debug """ self.debug( [ ('self.',self,[ 'ModeledDimensionGetKeyStrsList' ]) ] ) """ # Pick self.ModeledDimensionIntsList = self.ModelDeriveControllerVariable[Getter.GetMapStr]( *self.ModeledDimensionGetKeyStrsList ).ItemizedMapValueVariablesList else: # Default self.ModeledDimensionIntsList = [] # /################/# # map a join str with this # # debug """ self.debug( [ 'No we set the ModeledShapeStr', ("self.",self,[ 'ModeledDimensionGetKeyStrsList', 'ModeledDimensionIntsList' ]) ] ) """ # Bind with ModeledShapeStr setting self.ModeledShapeStr = ModelJoinStr.join( map( lambda __ModeledDescriptionGetKeyStr, __ModeledDimensionVariable: ModelJoinStr + str(__ModeledDescriptionGetKeyStr) + ModelDimensionStr + str(__ModeledDimensionVariable), self.ModeledDimensionGetKeyStrsList, self.ModeledDimensionIntsList, ) ) # debug """ self.debug( [ ('self.',self,['ModeledShapeStr']) ] ) """ # /#################/# # Adapt the name of the description model given the shape # # debug """ self.debug( [ 'Ok we have shaped', ('self.',self,['ModeledShapeStr']) ] ) """ # Get the new ModeledKeyStr if self.ModeledShapeStr != "": # debug """ self.debug( [ 'We set the new ModeledHdfSuffixStr', ('self.',self,['ModeledShapeStr','ModelTagStr']) ] ) """ # set self.ModeledHdfSuffixStr = self.ModeledShapeStr + ModelJoinStr + self.ModelTagStr else: # set self.ModeledHdfSuffixStr = self.ModelTagStr # debug """ self.debug( [ 'We have set the new ModeledHdfSuffixStr', ('self.',self,[ 'ModeledShapeStr', 'ModeledHdfSuffixStr' ]) ] ) """ # /#################/# # Set the good format for the Description tuples list # # Unnzip ModeledGetKeyStrsList = SYS.unzip(self.ModelingDescriptionTuplesList, [0]) # debug """ self.debug( [ ('Now change the shape of the shaping cols'), ('self.',self,[ 'ModelingDescriptionTuplesList', 'ModeledShapeIndexIntsList' ]) ] ) """ # map ModeledShapeDescriptionTuplesList = map( self.ModelingDescriptionTuplesList.__getitem__, self.ModeledShapeIndexIntsList ) # debug """ self.debug( [ 'ModeledShapeDescriptionTuplesList is '+str( ModeledShapeDescriptionTuplesList ), ('self.',self,['ModeledDescriptionDimensionIntsListsList']) ] ) """ # map ModeledShapeDescriptionTuplesList = map( lambda __ModeledShapeDescriptionTuple, __ModeledDescriptionDimensionIntsList: ( __ModeledShapeDescriptionTuple[0], __ModeledShapeDescriptionTuple[1], __ModeledShapeDescriptionTuple[2][0](shape=__ModeledDescriptionDimensionIntsList), ), ModeledShapeDescriptionTuplesList, self.ModeledDescriptionDimensionIntsListsList, ) # debug """ self.debug( [ 'ModeledShapeDescriptionTuplesList is '+str( ModeledShapeDescriptionTuplesList) ] ) """ # set the shaping cols map( lambda __ModeledIndexInt, __ModeledModelingDescriptionTuple: self.ModelingDescriptionTuplesList.__setitem__( __ModeledIndexInt, __ModeledModelingDescriptionTuple ), self.ModeledShapeIndexIntsList, ModeledShapeDescriptionTuplesList, ) # debug """ self.debug( [ "After the shape we check for the modeling description", ('self.',self,[ 'ModelingDescriptionTuplesList', 'ModelKeyStrsList' ] ) ] ) """ # /###################/# # Check maybe the Description was not yet done although there are ModelKeystrs # if len(self._ModelKeyStrsList) > len(self.ModelingDescriptionTuplesList): # bind self.propertize_setModelKeyStrsList(self._ModelKeyStrsList) # debug """ self.debug( [ "After the bind", ('self.',self,[ 'ModelingDescriptionTuplesList', 'ModelKeyStrsList' ] ) ] ) """ # /###################/# # Define the Description # # import import tables # Definition the DescriptionClass class DescriptionClass(tables.IsDescription): # Add (just like a unique KEY in mysql...) RowInt = tables.Int64Col() # debug """ self.debug( [ 'We add descriptions in the description Class', ('self.',self,['ModelingDescriptionTuplesList']) ] ) """ # set the cols in the ModelClass map( lambda __ModelingColumnTuple: DescriptionClass.columns.__setitem__( __ModelingColumnTuple[1], __ModelingColumnTuple[2] ), self.ModelingDescriptionTuplesList, ) # Give a name DescriptionClass.__name__ = SYS.getClassStrWithNameStr(self.ModelTagStr) # set the ModelClass if self.ModeledDescriptionClassesOrderedDict == None: self.ModeledDescriptionClassesOrderedDict = collections.OrderedDict() self.ModeledDescriptionClassesOrderedDict[self.ModelTagStr] = DescriptionClass # set the ModeledDescriptionClass self.ModeledDescriptionClass = DescriptionClass # /###################/# # Begin to set the hdf file # first look if we have to hdformat # # debug """ self.debug( [ 'We tabular for hdf here...', 'self.ModelDeriveControllerVariable.HdformatedFileVariable is ', str(self.ModelDeriveControllerVariable.HdformatedFileVariable) ] ) """ # set if self.ModeledHdfSuffixStr == "": self.ModeledHdfSuffixStr = self.ModelTagStr + "Table" # Check if self.ModelDeriveControllerVariable.HdformatedFileVariable == None: # /##################/# # If it is the top controller we have to hdformat # # debug """ self.debug( [ 'Look if the controller is the top one', 'self.ModelDeriveControllerVariable.ParentTopDeriveTeamerVariable==self.ModelDeriveControllerVariable', str(self.ModelDeriveControllerVariable.ParentTopDeriveTeamerVariable==self.ModelDeriveControllerVariable) ] ) """ # Check if ( self.ModelDeriveControllerVariable.ParentTopDeriveTeamerVariable == self.ModelDeriveControllerVariable ): # /##################/# # Set a default name # # Check if self.ModelDeriveControllerVariable.HdformatingFileKeyStr == "": # set self.ModelDeriveControllerVariable.HdformatingFileKeyStr = ( self.ModelDeriveControllerVariable.ControlTagStr + ".hdf5" ) # /##################/# # hdformat # # debug """ self.debug( [ 'We have to make hdformat the controller first...', ('self.ModelDeriveControllerVariable.', self.ModelDeriveControllerVariable, [ 'ControlTagStr' ]) ] ) """ # Hdformat self.ModelDeriveControllerVariable.hdformat() # debug """ self.debug( [ 'Ok the top controller has hdformated', ('self.ModelDeriveControllerVariable.', self.ModelDeriveControllerVariable, [ 'HdformatedFileVariable', 'ControlTagStr' ]) ] ) """ else: # /##################/# # If it is not the top we have just # to alias with the one of the top # # alias self.ModelDeriveControllerVariable.HdformatedFileVariable = ( self.ParentTopDeriveTeamerVariable.HdformatedFileVariable ) # /##################/# # Set the group path str to trigger # a set in the hdf # debug """ self.debug( [ 'We set in the hdf the group branch' ] ) """ # Set self.ModelDeriveControllerVariable.HdfGroupPathStr = self.ModelDeriveControllerVariable.ControlTagStr # debug """ self.debug( [ 'Ok the group is setted' ] ) """ # Link self.ModeledHdfTopFileVariable = self.ModelDeriveControllerVariable.HdformatedFileVariable # debug """ self.debug( [ 'Ok the hdf file is setted', ('self.',self,[ 'ModeledHdfTopFileVariable' ]) ] ) """ # /#################/# # Check for all the tables already defined here # # Check if self.ModeledHdfTopFileVariable != None: # debug """ self.debug( [ 'Looking for names of tables here', ( 'self.ModelDeriveControllerVariable.', self.ModelDeriveControllerVariable, ['HdfGroupPathStr'] ) ] ) """ # Definition Modeled attributes self.ModeledHdfGroupVariable = self.ModeledHdfTopFileVariable.getNode( self.ModelDeriveControllerVariable.HdfGroupPathStr ) # debug """ self.debug( [ ('looking for tables with the same Model Tag Str as : '), ('self.',self,['ModelTagStr']) ] ) """ # Get and sort self.ModeledHdfKeyStrsList = sorted( filter( lambda __KeyStr: __KeyStr.endswith(self.ModelTagStr), self.ModeledHdfGroupVariable._v_leaves.keys(), ) ) # update self.ModeledHdfTablesOrderedDict.update( map( lambda __ModeledKeyStr: ( __ModeledKeyStr, self.ModeledHdfGroupVariable._f_getChild(__ModeledKeyStr), ), self.ModeledHdfKeyStrsList, ) ) # debug """ self.debug( [ ("self.",self,[ 'ModeledHdfTablesOrderedDict' ]) ] ) """ # /################/# # Refind all the names of the tables # # debug """ self.debug( ('self.',self,[ 'ModeledHdfKeyStrsList', 'ModeledHdfSuffixStr', 'ModeledHdfKeyStr' ]) ) """ # Get the suffix Strs of all the tables and their index ModeledHdfList = SYS.unzip( map( lambda __StrsList: (__StrsList[1], ModelOrderStr.join(__StrsList[2:])), map(lambda __ModeledHdfKeyStr: __ModeledHdfKeyStr.split(ModelOrderStr), self.ModeledHdfKeyStrsList), ), [0, 1], ) # debug """ self.debug( [ 'All the corresponding table models are ', ('vars()[\'',vars(),['ModeledHdfList'],"\']") ] ) """ # /##################/# # Find if there are already some tables here and deduce the index of the table # # Unpack if it is possible if len(ModeledHdfList) > 0: # Unpack [ModeledHdfIndexIntsTuple, ModeledHdfSuffixStrsList] = ModeledHdfList # debug """ self.debug( [ 'There are already some tables', 'ModeledHdfSuffixStrsList is '+str(ModeledHdfSuffixStrsList), "self.ModeledHdfSuffixStr is "+str( self.ModeledHdfSuffixStr) ] ) """ if self.ModeledHdfSuffixStr not in ModeledHdfSuffixStrsList: # Increment the IndexStr ModeledHdfIndexInt = max(map(int, ModeledHdfIndexIntsTuple)) + 1 # Strify ModeledHdfIndexStr = str(ModeledHdfIndexInt) # debug """ self.debug('IndexStr of this new table is '+str(IndexStr)) """ else: # Get the already setted one ModeledHdfIndexStr = self.ModeledHdfKeyStrsList[ ModeledHdfSuffixStrsList.index(self.ModeledHdfSuffixStr) ].split(ModelOrderStr)[1] # Intify ModeledHdfIndexInt = (int)(ModeledHdfIndexStr) # debug """ self.debug('IndexStr of this not new table is '+str(IndexStr)) """ else: # debug """ self.debug('There are no tables here') """ # set to empty lists [ModeledHdfIndexIntsTuple, ModeledHdfSuffixStrsList] = [[], []] # Init the list ModeledHdfIndexInt = 0 # Strify ModeledHdfIndexStr = "0" # /##################/# # set the table key str # # debug """ self.debug( [ 'We set the table key str', ('self.',self,[ 'ModeledHdfSuffixStr' ]), 'ModeledHdfIndexStr is '+str(ModeledHdfIndexStr) ] ) """ # Bind with ModeledHdfKeyStr setting self.ModeledHdfKeyStr = ModelOrderStr + ModeledHdfIndexStr + ModelOrderStr + self.ModeledHdfSuffixStr # set the ModeledInt self.ModeledHdfIndexInt = ModeledHdfIndexInt # debug """ self.debug( [ 'Ok we have setted which hdf table', ('self.',self,[ 'ModeledHdfKeyStr', 'ModeledHdfIndexInt' ]), 'Now we create the table, or get it, depending if it is new or not', ('self.',self,[ 'ModeledHdfKeyStr', 'ModeledHdfTopFileVariable' ]) ] ) """ # Check if self.ModeledHdfKeyStr != "" and self.ModeledHdfTopFileVariable != None: # debug """ self.debug( [ ('self.',self,[ 'ModeledHdfKeyStr', 'ModeledHdfKeyStrsList' ]) ] ) """ # Create the Table if not already if self.ModeledHdfKeyStr not in self.ModeledHdfKeyStrsList: # debug """ self.debug( [ 'The table not exists', ] ) """ # Create the Table in the hdf5 self.ModeledHdfTable = self.ModeledHdfTopFileVariable.create_table( self.ModeledHdfGroupVariable, self.ModeledHdfKeyStr, self.ModeledDescriptionClass, self.ModeledDescriptionClass.__doc__ if self.ModeledDescriptionClass.__doc__ != None else "This is the " + self.ModeledDescriptionClass.__name__, ) # Append self.ModeledHdfKeyStrsList.append(self.ModeledHdfKeyStr) else: # debug """ self.debug( [ 'The table exists', "self.ModeledGroupVariable is "+str(self.ModeledGroupVariable) ] ) """ # Else just get it self.ModeledHdfTable = self.ModeledHdfGroupVariable._f_getChild(self.ModeledHdfKeyStr) # set the in the TablesOrderedDict self.ModeledHdfTablesOrderedDict[self.ModeledHdfKeyStr] = self.ModeledHdfTable # debug """ self.debug("self.ModeledHdfTablesOrderedDict is "+str( self.ModeledHdfTablesOrderedDict)) """ # debug """
def row(self,**_VariablesList): #debug self.debug('Start of the method') #debug self.debug( [ "self.ModelingModelStr is "+str(self.ModelingModelStr), "We are going to check if the joined model is already inserted...", "First look if self.JoinedModeledDatabase!={} is "+str(len(self.JoinedModeledDatabase)>0) ] ) #Check if self.JoinedDatabasePointer!=None: #debug self.debug("Ok there is a self.JoinedDatabasePointer") #Alias JoinedRetrievingIndexesList=self.JoinedRetrievingIndexesList JoinedRetrievingIndexesListKeyStr=self.JoinedRetrievingIndexesListKeyStr #debug self.debug('Check that this joined row is a new row in the table or not') #Get the GettingStrsList and GettedVariablesList GettingStrsList=SYS.unzip(self.JoinedModeledDatabase.ModelingColumningTuplesList,[0]) GettedVariablesList=self.pick(GettingStrsList) #Check if it was already rowed IsRowedBoolsList=map( lambda __Row: all( map( lambda __GettingStr,__GettedVariable: SYS.getIsEqualBool(__Row[__GettingStr],__GettedVariable), GettingStrsList, GettedVariablesList ) ), self.JoinedDatabasePointer.TabledTable.iterrows() ) #debug self.debug( [ 'self.StructuredKeyStr is '+str( self.StructuredKeyStr) if hasattr(self,'StructuredKeyStr') else "", 'IsRowedBoolsList is '+str(IsRowedBoolsList) ] ) #If it is rowed then set the JoinedRetrievingIndexesList try: RowInt=IsRowedBoolsList.index(True) except ValueError: RowInt=-1 #debug self.debug('So the corresponding RowInt is '+str(RowInt)) #set the RowInt JoinedRetrievingIndexesList[1]=RowInt #self.ModeledDict['JoinedOrderedDict'][JoinedRetrievingIndexesListKeyStr][1]=RowInt #Alias ''' JoinedOrderedDict=self.ModeledDict['JoinedOrderedDict'] JoinedRetrievingIndexesList=self.ModeledDict['JoinedOrderedDict'][JoinedRetrievingIndexesListKeyStr] #Give the JoinedRetrievingIndexesList to itself JoinedOrderedDict.__setitem__( JoinedRetrievingIndexesListKeyStr, JoinedRetrievingIndexesList ) ''' ''' #debug self.debug( [ 'JoinedOrderedDict is now', SYS.represent(JoinedOrderedDict) ] ) ''' #debug #self.debug('So we set the JoinedRetrievingIndexesList in the RowedIdentifiedOrderedDict') #Update the self.RowedIdentifiedOrderedDic #self.ModeledDict['RowedIdentifiedOrderedDict'].update(JoinedOrderedDict) #self.ModeledDict['RowedIdentifiedOrderedDict'].__setitem__( # JoinedRetrievingIndexesListKeyStr, # JoinedRetrievingIndexesList # ) #debug self.debug('End of the method')
def mimic_model(self): #/#################/# # Check if we have to shape before # #debug ''' self.debug( [ 'Do we have to shape before model', ('self.',self,['ModelingHdfBool']) ] ) ''' #Check if self.ModelingHdfBool: #shape self.shape() #/#################/# # Adapt the name of the descriptionmodel given the shape # #debug ''' self.debug( [ 'Ok we have shaped', ('self.',self,['ShapedStr']) ] ) ''' #Get the new ModeledKeyStr if self.ShapedStr!="": #debug ''' self.debug( [ 'We set the new ModeledDescriptionKeyStr', ('self.',self,['ShapedStr','ModelTagStr']) ] ) ''' #set self.ModeledDescriptionKeyStr=self.ShapedStr+ShapeJoiningStr+self.ModelTagStr else: self.ModeledDescriptionKeyStr=self.ModeledSuffixStr #debug ''' self.debug( [ 'We set the new ModeledDescriptionKeyStr', ('self.',self,['ShapedStr','ModeledDescriptionKeyStr']) ] ) ''' #/#################/# # Set the good format for the Description tuples list # #Unnzip ModeledGetKeyStrsList=SYS.unzip(self.ModelingDescriptionTuplesList,[0]) #debug ''' self.debug( [ ('Now change the shape of the shaping cols'), ('self.',self,[ 'ModelingDescriptionTuplesList', 'ShapedIndexIntsList' ]) ] ) ''' #map ShapedModelingDescriptionTuplesList=map( self.ModelingDescriptionTuplesList.__getitem__, self.ShapedIndexIntsList ) #debug ''' self.debug( [ 'ShapedModelingDescriptionTuplesList is '+str( ShapedModelingDescriptionTuplesList ), ('self.',self,['ShapedDescriptionDimensionIntsListsList']) ] ) ''' #map ModeledShapeDescriptionTuplesList=map( lambda __ShapedModelingDescriptionTuple,__ShapedDescriptionDimensionIntsList: ( __ShapedModelingDescriptionTuple[0], __ShapedModelingDescriptionTuple[1], __ShapedModelingDescriptionTuple[2][0]( shape=__ShapedDescriptionDimensionIntsList ) ), ShapedModelingDescriptionTuplesList, self.ShapedDescriptionDimensionIntsListsList ) #debug ''' self.debug( [ 'ModeledShapeDescriptionTuplesList is '+str( ModeledShapeDescriptionTuplesList) ] ) ''' #set the shaping cols map( lambda __ShapedIndexInt,__ShapedModelingDescriptionTuple: self.ModelingDescriptionTuplesList.__setitem__( __ShapedIndexInt, __ShapedModelingDescriptionTuple ), self.ShapedIndexIntsList, ModeledShapeDescriptionTuplesList ) #debug ''' self.debug( [ "After the shape", "Now self.ModelingDescriptionTuplesList is "+SYS._str( self.ModelingDescriptionTuplesList) ] ) ''' #/#################/# # Now specify the name of the table # #Check if self.ModelingHdfBool: #set self.ModeledHdfSuffixStr=self.ModelTagStr+'Table' #/#################/# # Now adapt also the name of the tables # #debug ''' self.debug( [ 'We add the ShapedStr to the ModeledSuffix Str ?', ('self.',self,[ 'ShapedStr', 'ModeledHdfSuffixStr' ]) ] ) ''' #Add the ShapedStr if self.ShapedStr!="": #debug ''' self.debug( [ ' ShapeJoiningStr not in self.ModeledSuffixStr is '+str( ShapeJoiningStr not in self.ModeledSuffixStr)) ] ) ''' #Check if ShapeJoiningStr not in self.ModeledHdfSuffixStr: #debug ''' self.debug('Yes we add') ''' #Add self.ModeledHdfSuffixStr=self.ShapedStr+ShapeJoiningStr+self.ModeledHdfSuffixStr #debug ''' self.debug( [ ('self.',self,['ModeledHdfSuffixStr']) ] ) ''' #/#################/# # base method # #debug ''' self.debug( 'Now we call the base model method' ) ''' #model then BaseClass.model(self)
def join( self, _ModelStr="", **_LocalJoiningVariablesDict ): #debug print('Joiner join method') print('_ModelStr is ',_ModelStr) if hasattr(self,"StructuredKeyStr"): print('self.StructuredKeyStr is ',self.StructuredKeyStr) print('') #Maybe we need to refresh some modeled and tabulared attributes if _ModelStr!="": #debug ''' print('_ModelStr is ',_ModelStr) print('') ''' #row self.tabular(_ModelStr) else: #set again the _ModelStr _ModelStr=self.ModeledDict['ModelStr'] #Init maybe the _LocalJoiningVariablesDict if 'IsJoiningBool' not in _LocalJoiningVariablesDict: #set IsScanningBool to False _LocalJoiningVariablesDict['IsJoiningBool']=False #Refresh attributes self.JoinedJoinedList=[-1,-1] self.JoinedOrderedDict=collections.OrderedDict() self.JoinedNodifiedOrderedDict=collections.OrderedDict() #Init a default False IsCheckingJoiningBool if 'IsCheckingJoiningBool' not in _LocalJoiningVariablesDict: _LocalJoiningVariablesDict['IsCheckingJoiningBool']=True #set the JoiningTuple if 'JoiningTuple' not in _LocalJoiningVariablesDict: #Case where there are joins if 'JoiningTuple' in self.ModeledDict: #set to the _LocalJoiningVariablesDict _LocalJoiningVariablesDict['JoiningTuple']=self.ModeledDict['JoiningTuple'] #Maybe we have to structure if self.IsGroupedBool==False: #debug ''' print('Join We have to structure first') if hasattr(self,"StructuredKeyStr"): print('self.StructuredKeyStr is ',self.StructuredKeyStr) ''' #Structure self.structure(self.ModeledDict['JoiningTuple'][0]) else: #set a default _LocalJoiningVariablesDict['JoiningTuple']=("","") #Nodify if there is the nodified objects if _LocalJoiningVariablesDict['IsJoiningBool']==False and _LocalJoiningVariablesDict['JoiningTuple' ][0]!="": #debug print('Joiner we are going to nodify the ',_LocalJoiningVariablesDict['JoiningTuple'][0]) if hasattr(self,'StructuredKeyStr'): print('self.StructuredKeyStr is ',self.StructuredKeyStr) print('') #Nodify self.nodify(_LocalJoiningVariablesDict['JoiningTuple'][0]) self.JoinedNodifiedOrderedDict=copy.copy(self.NodifiedOrderedDict) self.JoinedNodifiedNodeStr=self.NodifiedNodeStr self.JoinedNodifiedNodedStr=SYS.getDoneStrWithDoStr(self.NodifiedNodeStr) self.JoinedNodifiedNodingStr=SYS.getDoneStrWithDoStr(self.NodifiedNodeStr) #debug print('self.JoinedNodifiedOrderedDict is ',self.JoinedNodifiedOrderedDict) print('') #debug ''' print("_LocalJoiningVariablesDict['JoiningTuple'] is ", _LocalJoiningVariablesDict['JoiningTuple']) print('') ''' #If there is a joined model if len(self.JoinedNodifiedOrderedDict)==0 or _LocalJoiningVariablesDict['IsJoiningBool']: #debug ''' print('We have the right to join !') print("_LocalJoiningVariablesDict['IsJoiningBool']", _LocalJoiningVariablesDict['IsJoiningBool']) print('self.ModeledDict is ',self.ModeledDict) print('') ''' #Tabular for the _JoiningRowingStr if JoiningTuple is not None if _LocalJoiningVariablesDict['JoiningTuple'][1]!=None: self.JoinedModelStr=_LocalJoiningVariablesDict['JoiningTuple'][1] self.JoinedModeledStr=SYS.getDoneStrWithDoStr(self.JoinedModelStr) self.tabular(self.JoinedModelStr) self.JoinedModeledDict=copy.copy(self.ModeledDict) self.JoinedModeledKeyStr=self.ModeledKeyStr self.JoinedJoinedList[0]=self.ShapedTabularedInt self.JoinedTabularedTable=self.TabularedTable #debug ''' print('self.JoinedModeledDict is ',self.JoinedModeledDict) print('self.JoinedModeledKeyStr is ',self.JoinedModeledKeyStr) print('self.JoinedJoinedList is ',self.JoinedJoinedList) print('') ''' #Check if the actual setup is already rowed if _LocalJoiningVariablesDict['IsCheckingJoiningBool'] and self.JoinedJoinedList[1]==-1: #Definition the GettingStrsList and the GettedVariablesList if 'ColumningTuplesList' in self.JoinedModeledDict: #Get the GettingStrsList and GettedVariablesList GettingStrsList=SYS.unzip(self.JoinedModeledDict['ColumningTuplesList'],[0]) GettedVariablesList=self.pick(GettingStrsList) #debug ''' print(map( lambda __Row: map( lambda __GettingStr,__GettedVariable: all(__Row[__GettingStr]==__GettedVariable), GettingStrsList, GettedVariablesList ), JoinedTabularedTable.iterrows() ) ) ''' #Check if it was already rowed IsRowedBoolsList=map( lambda __Row: all( map( lambda __GettingStr,__GettedVariable: SYS.getIsEqualBool(__Row[__GettingStr],__GettedVariable), GettingStrsList, GettedVariablesList ) ), self.JoinedTabularedTable.iterrows() ) #debug ''' print('self.StructuredKeyStr is ',self.StructuredKeyStr) print('IsRowedBoolsList is ',IsRowedBoolsList) print('') ''' #If it is rowed then set the JoinedJoinedList try: IndexInt=IsRowedBoolsList.index(True) except ValueError: IndexInt=-1 self.JoinedJoinedList[1]=IndexInt #Give to itself JoinedOrderedSetTagStr=self.JoinedNodifiedNodedStr+'JoinedOrderedDict' if hasattr(self,JoinedOrderedSetTagStr): self.JoinedOrderedDict=getattr(self,JoinedOrderedSetTagStr) if self.JoinedOrderedDict==None: self.JoinedOrderedDict=collections.OrderedDict() self.JoinedOrderedDict.__setitem__( self.JoinedJoinedListKeyStr,self.JoinedJoinedList ) if self.JoinedNodifiedNodedStr!="": ParentPointer=getattr(self,self.JoinedNodifiedNodedStr+'ParentPointer') if ParentPointer!=None: #Give to the Parent JoinedOrderedDict=getattr(ParentPointer,JoinedOrderedSetTagStr) JoinedOrderedDict[getattr(self,self.JoinedNodifiedNodedStr+'KeyStr' )+self.JoinedJoinedListKeyStr]=self.JoinedJoinedList #debug ''' print('JoinedModeledDict is ',JoinedModeledDict) print('JoinedList is ',JoinedList) print('') ''' #Tabular again to set again the ModeledDict self.tabular(_ModelStr) else: #debug ''' print('This either a not last level of child or it is not yet authorized to join') print('self.JoinedNodifiedOrderedDict.values() is ',self.JoinedNodifiedOrderedDict.values()) print('len(self.NodifiedOrderedDict.values()) is ',len(self.NodifiedOrderedDict.values())) print("_LocalJoiningVariablesDict['IsJoiningBool']",_LocalJoiningVariablesDict['IsJoiningBool']) print('so join the deeper children groups first') print('') ''' map( lambda __JoiningObjects: __JoiningObjects.join( self.ModeledDict['ModelStr'], **_LocalJoiningVariablesDict ), self.JoinedNodifiedOrderedDict.values() ) ''' print('The deeper children groups are joined now') print('So join here !') print('') ''' self.join( self.ModeledDict['ModelStr'], **dict( _LocalJoiningVariablesDict,**{'IsJoiningBool':True} ) ) #Return self return self
def shape(self,_DimensionsTupleList=None,**_KwargVariablesDict): #Init if self.ShapingDimensionsTupleList==None: self.ShapingDimensionsTupleList=[] #Init if self.ShapedGettingStrsList==None: self.ShapedGettingStrsList=[] if self.ShapedColClassAndGettingStrTuplesList==None: self.ShapedColClassAndGettingStrTuplesList=[] #set the ShapedOldModelingDescriptionTuplesList self.ShapedCopyModelingDescriptionTuplesList=copy.copy(self.ModelingDescriptionTuplesList) #debug ''' self.debug('We are going to filter the shaping tuples among the columning tuples') ''' #Unpack [ self.ShapedModelingDescriptionTuplesList, self.ShapedNotModelingDescriptionTuplesList ]=SYS.groupby( lambda __ColumnTuple: type(__ColumnTuple[1])==tuple, self.ModelingDescriptionTuplesList, ) #set the ShapedGettingStrsList and ShapedColClassAndGettingStrTuplesList FilteredList=map(list, SYS.unzip(self.ShapedModelingDescriptionTuplesList,[0,1]) ) if len(FilteredList)>0: [ self.ShapedGettingStrsList, self.ShapedColClassAndGettingStrTuplesList ]=FilteredList #debug ''' self.debug( ('self.',self,[ 'ShapedNotModelingDescriptionTuplesList', 'ShapedGettingStrsList', 'ShapedColClassAndGettingStrTuplesList' ] ) ) ''' #set the ShapedGettingStrsList self.ShapedDimensionKeyStrsList=list(set(SYS.unzip( self.ShapedColClassAndGettingStrTuplesList,[1] ))) #debug ''' self.debug(("self.",self,['ShapedGettingStrsList'])) ''' #set the ShapedVariablePointer to get inside the shaped variables if self.ShapedVariablePointer==None and hasattr(self,'NodedDatabaseParentPointer'): self.ShapedVariablePointer=self.NodedDatabaseParentPointer #set the ShapedVariablesList setting self.ShapedDimensionVariablesList=map( lambda __GettedVariable: (__GettedVariable) if type(__GettedVariable)==int else tuple(__GettedVariable), map( lambda __ShapedDimensionKeyStr: self.ShapedVariablePointer[__ShapedDimensionKeyStr], self.ShapedDimensionKeyStrsList ) ) #Bind with ModeledShapedStr setting self.ShapedStr=ShapingJoiningStr.join( map( lambda __ShapingGettingStr,__ShapedVariable: ShapingJoiningStr+str( __ShapingGettingStr )+ShapingTuplingStr+str( __ShapedVariable), self.ShapedDimensionKeyStrsList, self.ShapedDimensionVariablesList ) ) #debug ''' self.debug(('self.',self,['ShapedDimensionVariablesList','ShapedStr'])) ''' #<NotHook> #Return self return self
def do_parent(self): #debug ''' self.debug(('self.',self,[ ])) ''' #Check of a parent pointer if self.NodePointDeriveNoder!=None: #debug ''' self.debug('We are going to node the parent pointer') ''' #Parent the parent maybe if self.ParentingWalkBool: #parent the parent self.NodePointDeriveNoder.parent( self.ParentingTopPickVariablesList, self.ParentingWalkBool ) #set self.ParentedDeriveParentersList=[self.NodePointDeriveNoder ]+self.NodePointDeriveNoder.ParentedDeriveParentersList self.ParentedNodeCollectionStrsList=[self.NodedCollectionStr ]+self.NodePointDeriveNoder.ParentedNodeCollectionStrsList self.ParentedNodeCollectionStrsList.reverse() #definition ParentedNodePathStrsList=map( lambda __ParentedDeriveParenter: __ParentedDeriveParenter.NodeKeyStr, self.ParentedDeriveParentersList ) ParentedNodePathStrsList.reverse() #definition ParentedTotalPathTuplesList=map( lambda __ParentedDeriveParenter: ( Noder.NodingPrefixGetStr+__ParentedDeriveParenter.NodeCollectionStr+Noder.NodingSuffixGetStr, __ParentedDeriveParenter.NodeKeyStr ), self.ParentedDeriveParentersList ) ParentedTotalPathTuplesList.reverse() #Debug ''' self.debug('ParentedTotalPathTuplesList is '+str(ParentedTotalPathTuplesList)) ''' #set self.ParentedNodePathStr=Pather.PathPrefixStr.join( SYS.unzip(ParentedTotalPathTuplesList,[1]) ) self.ParentedCollectionPathStr=Pather.PathPrefixStr.join( SYS.unzip(ParentedTotalPathTuplesList,[0]) ) self.ParentedTotalPathStr=Pather.PathPrefixStr.join( map( lambda __ParentedTotalPathTuple: __ParentedTotalPathTuple[0]+__ParentedTotalPathTuple[1], ParentedTotalPathTuplesList ) ) #Check if len(self.ParentedDeriveParentersList)>0: self.ParentedTopDeriveParenterVariable=self.ParentedDeriveParentersList[-1] else: self.ParentedTopDeriveParenterVariable=self #Link self.update( zip( self.ParentingTopPickVariablesList, self.ParentedTopDeriveParenterVariable.pick( self.ParentingTopPickVariablesList ) ) ) else: self.ParentedTopDeriveParenterVariable=self