Exemplo n.º 1
0
def getDoing(_InstanceVariable,_DoClassVariable=None):

	#check
	DoClassesList=SYS.GetList(_DoClassVariable,SYS)
	if len(DoClassesList)==0:
		DoClassesList=_InstanceVariable.__class__.MroDoerClassesList

	#Debug
	"""
	print('l 83 Doer')
	print('DoClassesList is ',DoClassesList)
	print('')
	"""

	#return
	return collections.OrderedDict(
		SYS.sum(
			map(
				lambda __DoClass:
				zip(
					__DoClass.DoingAttributeVariablesOrderedDict.keys(),
				map(
						lambda __DoneKeyStr:
						getattr(_InstanceVariable,__DoneKeyStr),
						__DoClass.DoingAttributeVariablesOrderedDict.keys()
					)
				),
				DoClassesList
			)
		)
	)
	def mimic_get(self):

		#debug
		'''
		self.debug(
				('self.',self,[
						'GettingKeyVariable',
					])
			)
		'''

		#Check
		if type(self.GettingKeyVariable)==str:

			#Check
			if self.GettingKeyVariable.startswith(CommandAddStr):

				#split
				AddGetKeyStrsList=self.GettingKeyVariable.split(CommandAddStr)[1:]

				#debug
				'''
				self.debug(
					[
						'We map get',
						'AddGetKeyStrsList is '+str(AddGetKeyStrsList) 
					]
				)
				'''
				
				#map get
				AddVariablesList=self[
						Getter.GetMapStr
					](*AddGetKeyStrsList).ItemizedMapValueVariablesList

				#debug
				'''
				self.debug(
					[
						'We sum now',
						'AddVariablesList is '+SYS._str(AddVariablesList) 
					]
				)	
				'''

				#map get
				self.GettedValueVariable=SYS.sum(AddVariablesList)

				#return
				return {'HookingIsBool':False}

		#return
		return BaseClass.get(self)
Exemplo n.º 3
0
	def viewNetwork(self):

		#
		# Maybe erase
		#

		del self.TeamDict['Panels']


		#
		# Plot the transfer functions
		#

		#Check 
		if len(self.ViewingColorStrsList)!=self.StationarizingUnitsInt:

			#set
			self.ViewingColorStrsList = SYS.getColorTuplesList(
					_FromColorStr='blue',
					_ToColorStr='black',
					_SampleInt=self.StationarizingUnitsInt,
					_PlotBool=False
				)

		#Check
		if len(self.ViewingLabelStrsList)!=self.StationarizingUnitsInt:

			#set
			self.ViewingLabelStrsList=map(
				lambda _Variable:
				_Variable.ManagementTagStr,
				self.TeamDict['Populations'].ManagementDict.values()
			)

		#Debug
		'''
		self.debug(
			[
				('self.',self,[
						'ViewingColorStrsList',
						'ViewingLabelStrsList'
					])
			]
		)
		'''

		#debug
		'''
		self.debug(
			[
				"We transfer view network here"
			]
		)
		'''

		#call
		ViewedTransferVariable = self.getTeamer(
				'Panels'
			).getManager(
				'Transfer'
			)

		ViewedChartsVariable=ViewedTransferVariable.getTeamer(
				'Charts'
			)

		#xlim
		xlimList =  [self.TransferedScanFrequencyFloatsArray[0],self.TransferedScanFrequencyFloatsArray[-1]]

		#
		# Amplitude
		#

		#plot
		ViewedAmplitudeChartVariable = ViewedChartsVariable.getManager('Amplitude')

		#get
		ViewedAmplitudeDrawVariable = ViewedAmplitudeChartVariable.getTeamer(
				'Draws'
			).getManager('0')


		#debug
		self.debug(
			[
				('self.',self,[
						'StationarizedRateFloatsArraysList',
						'StationarizingRateVariable'
					])
			]
		)

		#set
		yLimAmplitudeList=[
			self.TransferedNormRateAmplitudeFloatsArray.min(),
			self.TransferedNormRateAmplitudeFloatsArray.max()
		]
		yTickAmplitudeList=[0.,0.5,1.]

		#map
		ViewedAmplitudeDrawVariable.PyplotingDrawVariable = map(
			lambda __IndexInt:
			('plot',{
					'#liarg':[
						self.TransferedScanFrequencyFloatsArray,
						self.TransferedNormRateAmplitudeFloatsArray[__IndexInt,:]
					],
					'#kwarg':{
							'linestyle':'-',
							'linewidth':5,
							'color':self.ViewingColorStrsList[__IndexInt],
							'label':self.ViewingLabelStrsList[__IndexInt]
						}
				}),
			xrange(len(self.TeamDict['Populations'].ManagementDict))
		)

		#set log
		ViewedAmplitudeChartVariable.PyplotingChartVariable=[
				('set_xscale','log'),
				('set_xlim',xlimList),
				('set_xticklabels',[]),
				('set_yticks',yTickAmplitudeList),
				('set_yticklabels',map(lambda __Float:'$'+str(__Float)+'$',yTickAmplitudeList)),
				('set_ylabel',"$amplitude\ r_{a1}/r_{a0}$")
			]

		ViewedAmplitudeChartVariable.PyplotingLegendDict={
			'fontsize':10,
			'ncol':2 if self.StationarizingUnitsInt>3 else 1
		}

		#
		# Phase
		#

		#plot
		ViewedPhaseChartVariable = ViewedChartsVariable.getManager('Phase')

		#get
		ViewedPhaseDrawVariable = ViewedPhaseChartVariable.getTeamer(
				'Draws'
			).getManager('0')

		#set
		#yLimPhaseList=[TransferedNormRatePhaseFloatsArray.min(),TransferedNormRatePhaseFloatsArray.max()]
		yLimPhaseList=[-180.,180.]
		yTickPhaseList=[-180,-90,0,90,180]

		#map
		ViewedPhaseDrawVariable.PyplotingDrawVariable = map(
			lambda __IndexInt:
			('plot',{
					'#liarg':[
						self.TransferedScanFrequencyFloatsArray,
						#(180./np.pi)*np.array(map(
						#	SYS.getArgumentVariable,
						#	self.TransferedRateComplexesArray[__IndexInt,:]
						#))
						self.TransferedNormRatePhaseFloatsArray[__IndexInt,:]
					],
					'#kwarg':{
							'linestyle':'-',
							'linewidth':5,
							'color':self.ViewingColorStrsList[__IndexInt]
						}
				}),
			range(len(self.TeamDict['Populations'].ManagementDict))[1:]
		)+[
			('plot',{
					'#liarg':[
						self.TransferedScanFrequencyFloatsArray,
						#(180./np.pi)*np.array(map(
						#	SYS.getArgumentVariable,
						#	self.TransferedRateComplexesArray[__IndexInt,:]
						#))
						self.TransferedNormRatePhaseFloatsArray[0,:]
					],
					'#kwarg':{
							'linestyle':'--',
							'linewidth':3,
							'color':self.ViewingColorStrsList[0]
						}
				})
		]

		#set log
		ViewedPhaseChartVariable.PyplotingChartVariable=[
				('plot',{
					'#liarg':[	
							xlimList,
							[0.,0.]
						],
					'#kwarg':{
							'linestyle':'--',
							'linewidth':1,
							'color':"black"
						}
					}

				),
				('set_xscale','log'),
				('set_xlim',xlimList),
				('set_xlabel',"$frequency (Hz)$"),
				('set_ylim',yLimPhaseList),
				('set_ylabel',"$phase$"),
				('set_yticks',yTickPhaseList),
				('set_yticklabels',map(lambda __Float:'$'+str(__Float)+'$',yTickPhaseList))
			]

		#
		# Plot max but just (for the first)
		#

		#map
		ViewedAmplitudeDrawVariable.PyplotingDrawVariable += SYS.sum(map(
			lambda __IndexInt:
			map(
				lambda __FourierMaxTuple:
				('plot',{
					'#liarg':[
						[__FourierMaxTuple[0]]*2,
						yLimAmplitudeList
					],
					'#kwarg':{
							'linestyle':'--',
							'linewidth':1,
							#'color':self.ViewingColorStrsList[__IndexInt]
							'color':"black"
						}
				}),
				self.TransferedPeakVariable[__IndexInt]
			),
			range(len(self.TeamDict['Populations'].ManagementDict))[:1]
		))

		#map
		'''
		ViewedPhaseDrawVariable.PyplotingDrawVariable += SYS.sum(map(
			lambda __IndexInt:
			map(
				lambda __FourierMaxTuple:
				('plot',{
					'#liarg':[
						[__FourierMaxTuple[0]]*2,
						yLimPhaseList
					],
					'#kwarg':{
							'linestyle':'--',
							'linewidth':1,
							#'color':self.ViewingColorStrsList[__IndexInt]
							'color':"black"
						}
				}),
				self.NumscipiedFourierMaxTupleFloatsArray[__IndexInt]
			),
			range(len(self.TeamDict['Populations'].ManagementDict))[:1]
		))	
		'''

		#map
		ViewedPhaseDrawVariable.PyplotingDrawVariable += SYS.sum(map(
			lambda __IndexInt:
			SYS.sum(map(
				lambda __FourierMaxTuple:
				map(
					lambda __PhaseFloat,_IndInt:
					('plot',{
						'#liarg':[
							__FourierMaxTuple[0],
							__PhaseFloat
						],
						'#kwarg':{
								'linestyle':'',
								'marker':"o",
								'markersize':5,
								'color':self.ViewingColorStrsList[_IndInt]
								#'color':"black"
							}
					}),
					__FourierMaxTuple[1][1:],
					xrange(len(__FourierMaxTuple[1][1:]))
				),
				self.TransferedPhaseVariable[__IndexInt]
			)),
			range(len(self.TeamDict['Populations'].ManagementDict))[:1]
		))	

		#
		# Recapepete
		#

		#mapSet
		self.mapSet(
			{
				'PyplotingFigureVariable':{
					'figsize':(10,10)
				},
				'PyplotingGridVariable':(40,30),
				'-Panels':[
					(
						'|Transfer',
						{
							'PyplotingTextVariable':[-0.6,0.],
							'PyplotingShapeVariable':[10,10],
							'-Charts':{
								'|Amplitude':{
								},
								'|Phase':{
									'PyplotingShiftVariable':[2,0]
								}
							}
						}
					)
				]
			}
		)




		#base
		BaseClass.viewNetwork(self)
def setDefaultMutable(
	_InstanceVariable,
	_ClassVariable,
	_AttributeKeyVariable=None,
	**_KwargVariablesDict
):
	
	#get
	DefaultClassesList=SYS.GetList(_ClassVariable,SYS)

	#Set
	if 'ForceSetIsBool' in _KwargVariablesDict:
		ForceSetIsBool=_KwargVariablesDict['ForceSetIsBool']
	else:
		ForceSetIsBool=False

	#/#################/#
	# Get all the attribute to default set again and filter 
	# the ones that have not the right
	#

	#Check
	if _AttributeKeyVariable==None:
		AttributeKeyStrsList=SYS.sum(
			map(
				lambda __DefaultClass:
				__DefaultClass.DefaultSpecificKeyStrsList,
				DefaultClassesList
			)
		)
	elif type(_AttributeKeyVariable)!=list:
		AttributeKeyStrsList=[AttributeKeyVariable]
	else:
		AttributeKeyStrsList=_AttributeKeyVariable
		
	#/################/#
	# map an init for the mutable variables by detecting them at the level of the class 
	# they are None
	#

	#map
	TypeClassesList=map(
			lambda __AttributeKeyStr:
			SYS.getTypeClassWithTypeStr(
				SYS.getTypeStrWithKeyStr(__AttributeKeyStr)
			)
			if (
					SYS.getIsNoneBool(
						getattr(
							_InstanceVariable,
							__AttributeKeyStr
						)
					) 
					if ForceSetIsBool==False 
					else True
				)
			and getattr(
				_InstanceVariable.__class__,
				__AttributeKeyStr
			)==None
			else None.__class__,
			AttributeKeyStrsList
	)

	#debug
	'''
	print('l 122 Defaultor')
	print('AttributeKeyStrsList is '+str(AttributeKeyStrsList))
	print('TypeClassesList is '+str(TypeClassesList))
	print('')
	'''

	#set in the instance
	map(
			lambda __AttributeKeyStr,__TypeClass:
			setattr(
					_InstanceVariable,
					__AttributeKeyStr,
					__TypeClass()
			)
			if __TypeClass!=None.__class__ 
			else None,
			AttributeKeyStrsList,
			TypeClassesList
	)

	#return 
	return _InstanceVariable
def setDefault(
	_InstanceVariable,
	_ClassVariable,
	_AttributeKeyVariable=None,
	**_KwargVariablesDict
):
	
	#/#################/#
	# Get all the default classes
	#

	#get
	DefaultClassesList=SYS.GetList(_ClassVariable,SYS)

	#Debug
	print('setDefault l 168')
	print('DefaultClassesList is ')
	print(DefaultClassesList)
	print('')

	#/#################/#
	# Get all the attribute to default set again and filter 
	# the ones that have not the right
	#

	#Check
	if _AttributeKeyVariable==None:
		AttributeKeyStrsList=SYS.sum(
			map(
				lambda __DefaultClass:
				__DefaultClass.DefaultSpecificKeyStrsList,
				DefaultClassesList
			)
		)
	elif type(_AttributeKeyVariable)!=list:
		AttributeKeyStrsList=[_AttributeKeyVariable]
	else:
		AttributeKeyStrsList=_AttributeKeyVariable

	#Check
	if 'DefaultNotSetTagStrsList' in _KwargVariablesDict:

		#filter
		AttributeKeyStrsList=SYS._filter(
				lambda __AttributeKeyStr:
				__AttributeKeyStr not in _KwargVariablesDict['DefaultNotSetTagStrsList'],
				AttributeKeyStrsList
			)
		
	#Debug
	print('Defaultor l 194')
	print('AttributeKeyStrsList is ')
	print(AttributeKeyStrsList)
	print('')

	#map a set for all the class attributes into the instance
	map(
			lambda __AttributeKeyStr:
			_InstanceVariable.__setattr__
			(
				__AttributeKeyStr,
				getattr(
						_InstanceVariable.__class__,
						__AttributeKeyStr
					)
			),
			AttributeKeyStrsList
		)

	#set
	'''
	setDefaultMutable(
		_InstanceVariable,
		DefaultClassesList,
		AttributeKeyStrsList
	)
	'''

	#return 
	return _InstanceVariable
plt.subplot(141)
plt.plot(
	SampleFloatsArray,
	MyNumscipyer.NumscipiedValueFloatsArray.T
)
plt.subplot(142)
plt.plot(
	MyNumscipyer.NumscipiedFourierFrequencyFloatsArray,
	MyNumscipyer.NumscipiedFourierAmplitudeFloatsArray.T
)
map(
	lambda __NumscipiedFourierMaxTupleFloat:
	plt.plot(
		*__NumscipiedFourierMaxTupleFloat,
		marker='o'
	),
	SYS.flat(MyNumscipyer.NumscipiedFourierMaxTupleFloatsArray)
)
plt.subplot(143)
plt.plot(
	MyNumscipyer.NumscipiedFourierFrequencyFloatsArray,
	MyNumscipyer.NumscipiedFourierPhaseFloatsArray.T
)
plt.subplot(144)
plt.plot(
	MyNumscipyer.NumscipiedFourierFrequencyFloatsArray,
	SYS.sum(MyNumscipyer.NumscipiedFourierCrossPhaseFloatsArray).T
)
plt.show()

#ImportModules
import ShareYourSystem as SYS

#init
MyList=[
	[2,3],
	[3,4,[5,9]]
]

#print
print(SYS.sum(MyList))

#print
print(SYS.flat(MyList))

#array
MyArray=SYS.numpy.array(
	[
		[2,3],
		[3,4]
	]
)

#print
print(SYS.sum(MyArray))

#array
MyArray=SYS.numpy.array(
	[
		[[2,1],[3,5]],
		[[3],[4,66]]
Exemplo n.º 8
0
	def do_explore(self):
		""" """

		#debug
		'''
		self.debug(
			[
				"We explore here"
			]
		)
		'''

		#Check
		if self.ExploredSucessesInt < self.ExploringSuccessesInt:

			#
			# Prepare
			#

			#Check
			if hasattr(self.ExploringRangeVariable,'items'):
				self.ExploredRangeTuplesList=self.ExploringRangeVariable.items()

			#Check
			if hasattr(self.ExploringConditionVariable,'items'):
				self.ExploredConditionTuplesList=self.ExploringConditionVariable.items()

			#Check
			if len(self.ExploredRangeTuplesList)!=len(self.ExploredParameterStrsList):
				self.ExploredParameterStrsList = map(
					lambda __TuplesList:__TuplesList[0],
					self.ExploredRangeTuplesList
				)

			#
			# Prepare Children
			#

			#Check
			if self.ExploredManagersVariable == None:

				#debug
				self.debug(
					[
						('self.',self,[
								'TeamingClassesDict'
							])
					]
				)

				#sum
				self.ExploredManagersVariable = SYS.sum(
					SYS.filterNone(
						map(
							lambda __TeamStr:
							self.TeamDict[__TeamStr].ManagementDict.values()
							if __TeamStr in self.TeamDict
							else None,
							self.TeamingClassesDict.keys()
						)
					)
				)

				#Check
				if self.ParentDeriveTeamerVariable == None:

					#coordinate one first time
					self.coordinate(self.ExploringMethodStr)

					#set
					ExploredTopMethodStr=self.ExploringMethodStr+"Top"

					#Check
					if hasattr(self,ExploredTopMethodStr):

						#set
						self.ExploredMethodStr = ExploredTopMethodStr

			if self.ExploredMethodStr=="":
				self.ExploredMethodStr = self.ExploringMethodStr

			#
			# Pick
			#

			#Check
			while self.ExploringTrialsInt > self.ExploredTrialsInt :

				#count
				self.ExploredTrialsInt +=1

				#debug
				'''
				self.debug(
					[
						"We test with a new trial set",
						('self.',self,[
								'ExploredTrialsInt'
							])
					]
				)
				'''

				#
				# Init
				#

				#init the ranges
				map(
					lambda __TuplesList:
					setattr(
						self,
						__TuplesList[0],
						__TuplesList[1](self)
					),
					self.ExploredRangeTuplesList
				)

				#
				# Check Children
				#

				#debug
				self.debug(
					[
						"We first check the children"
					]
				)

				#map
				map(
					lambda __Manager:
					__Manager.explore(
						_MethodStr = self.ExploringMethodStr,
						_ConditionVariable = SYS.update(
							self.ExploringConditionVariable,
							{
								"explore":getattr(
									self.__class__,
									self.ExploringMethodStr+__Manager.CoordinatedParentSingularStr
								)
							}
						) if hasattr(__Manager,self.ExploringMethodStr+__Manager.CoordinatedParentSingularStr)
						else self.ExploringConditionVariable,
						_SuccessesInt=1
					)
					if __Manager.ExploredCheckBool==False
					else None,
					self.ExploredManagersVariable
				)

				#
				# Test
				#

				#debug
				self.debug(
					[
						"Now we do the local test",
						('self.',self,[
								'ExploringMethodStr',
								'ExploredMethodStr'
							])
					]
				)

				#call
				getattr(self,self.ExploredMethodStr)()

				#
				# Each Check
				#

				#init
				self.ExploredCheckBool = True

				#loop
				for __ConditionTuple in self.ExploredConditionTuplesList:

					#Check
					if __ConditionTuple[1](self) == False:

						#set
						self.ExploredCheckBool = False

						#break
						break

				#debug
				'''
				self.debug(
					[
						('self.',self,[
								'ExploredCheckBool'
							])
					]
				)
				'''

				#
				# Total Check
				#

				#Check
				if self.ExploredCheckBool:

					#count
					self.ExploredSucessesInt += 1

					#keep
					self.ExploredStoreTuplesListsList.append(
						map(
							lambda __KeyStr:
							(__KeyStr,getattr(self,__KeyStr)),
							self.ExploredKeepStrsList+self.ExploredParameterStrsList
						)
					)

					#debug
					'''
					self.debug(
						[
							"it is a sucess",
							('self.',self,['ExploredStoreTuplesListsList'])
						]
					)
					'''

					#break maybe
					if self.ExploredSucessesInt >= self.ExploringSuccessesInt:
						
						#break
						break

			#debug
			'''
			self.debug(
				[
					('We reached the max of Trials ot pick')
				]
			)
			'''
			
		else:

			#debug
			'''
Exemplo n.º 9
0
def setDefault(
	_InstanceVariable,
	_ClassVariable,
	_AttributeKeyVariable=None,
	**_KwargVariablesDict
):
	
	#/#################/#
	# Get all the default classes
	#

	#get
	DefaultClassesList=SYS.GetList(_ClassVariable,SYS)

	#Debug
	'''
	print('setDefault l 168')
	print('DefaultClassesList is ')
	print(DefaultClassesList)
	print('')
	'''

	#/#################/#
	# Get all the attribute to default set again and filter 
	# the ones that have not the right
	#

	#Check
	if _AttributeKeyVariable==None:
		AttributeKeyStrsList=SYS.sum(
			map(
				lambda __DefaultClass:
				__DefaultClass.DefaultSpecificKeyStrsList,
				DefaultClassesList
			)
		)
	elif type(_AttributeKeyVariable)!=list:
		AttributeKeyStrsList=[_AttributeKeyVariable]
	else:
		AttributeKeyStrsList=_AttributeKeyVariable

	#Check
	if 'DefaultNotSetTagStrsList' in _KwargVariablesDict:

		#filter
		AttributeKeyStrsList=SYS._filter(
				lambda __AttributeKeyStr:
				__AttributeKeyStr not in _KwargVariablesDict['DefaultNotSetTagStrsList'],
				AttributeKeyStrsList
			)
		
	#Debug
	'''
	print('Defaultor l 194')
	print('AttributeKeyStrsList is ')
	print(AttributeKeyStrsList)
	print('')
	'''

	#/#################/#
	# Reset the attributes by taking the ones in the class
	#

	#map 
	map(
			lambda __AttributeKeyStr:
			_InstanceVariable.__setattr__
			(
				__AttributeKeyStr,
				getattr(
						_InstanceVariable.__class__,
						__AttributeKeyStr
					)
			),
			AttributeKeyStrsList
		)

	#/#################/#
	# Reset maybe the mutable attributes by initiating with their type
	#

	#Check
	if 'DefaultMutableBool' in _KwargVariablesDict:
		DefaultMutableBool=_KwargVariablesDict['DefaultMutableBool']
	else:
		DefaultMutableBool=False

	#Check
	if DefaultMutableBool:

		#set
		setDefaultMutable(
			_InstanceVariable,
			DefaultClassesList,
			AttributeKeyStrsList
		)

	#return 
	return _InstanceVariable