PEATSA/Core/Environment.py
def balanceArrays(self, arrayFragment):
	
		'''Redistributes the elements in a set of arrays equally across the nodes'''
		
		if Environment.isParallel:
			import pypar
			if self.isRoot():
				completeArray = arrayFragment
				for i in range(1, pypar.size()):
					fragment = pypar.receive(i)
					completeArray.extend(fragment)
				
				#Divide it up
				divisions = self._divideArray(completeArray)
				
				#Send the fragments
				for i in range(1, pypar.size()):
					start, end = divisions[i]
					pypar.send(completeArray[start:end], i)
					
				self.output('[ENV] Rebalanced array divisions %s' % divisions)	
					
				#Assign root fragment	
				start, end = divisions[0]	
				arrayFragment = completeArray[start:end]
			else:
				#Send the fragment
				pypar.send(arrayFragment, 0)
				#Retrieve the array
				arrayFragment = pypar.receive(0)
		else:
			completeArray = arrayFragment
		
		return arrayFragment
Redistributes the elements in a set of arrays equally across the nodes
Redistributes the elements in a set of arrays equally across the nodes
Redistributes the elements in a set of arrays equally across the nodes
def balanceArrays(self, arrayFragment):
		if Environment.isParallel:
			import pypar
			if self.isRoot():
				completeArray = arrayFragment
				for i in range(1, pypar.size()):
					fragment = pypar.receive(i)
					completeArray.extend(fragment)
				divisions = self._divideArray(completeArray)
				for i in range(1, pypar.size()):
					start, end = divisions[i]
					pypar.send(completeArray[start:end], i)
				self.output('[ENV] Rebalanced array divisions %s' % divisions)	
				start, end = divisions[0]	
				arrayFragment = completeArray[start:end]
			else:
				pypar.send(arrayFragment, 0)
				arrayFragment = pypar.receive(0)
		else:
			completeArray = arrayFragment
		return arrayFragment
def balanceArrays ( self , arrayFragment ) : if Environment . isParallel : import pypar if self . isRoot ( ) : completeArray = arrayFragment for i in range ( 1 , pypar . size ( ) ) : fragment = pypar . receive ( i ) completeArray . extend ( fragment ) divisions = self . _divideArray ( completeArray ) for i in range ( 1 , pypar . size ( ) ) : start , end = divisions [ i ] pypar . send ( completeArray [ start : end ] , i ) self . output ( '[ENV] Rebalanced array divisions %s' % divisions ) start , end = divisions [ 0 ] arrayFragment = completeArray [ start : end ] else : pypar . send ( arrayFragment , 0 ) arrayFragment = pypar . receive ( 0 ) else : completeArray = arrayFragment return arrayFragment
Redistributes the elements in a set of arrays equally across the nodes
Redistributes the elements in a set of arrays equally across the nodes
'''Redistributes the elements in a set of arrays equally across the nodes''' #Divide it up #Send the fragments #Assign root fragment	 #Send the fragment #Retrieve the array
self
arrayFragment