def OutputEvaluationResults(dendObj, testRun, verbosePrint, evaluateClassifier):
	'''
	If training is performed weights produced are saved to a text file.  The file
	is cleared and formatting rules are applied to put it in a format that can be
	imported into a numpy array.
	Note: this could use code for validating weight files created but that is not writen so far

	Reference: http://stackoverflow.com/questions/22821460/numpy-save-2d-array-to-text-file	
	'''

	if (evaluateClassifier == False):
		weightsFile = open('./furtherFormulas/savedWeights.txt', 'w')
		weightsFile.close()
		weightsFile = open('./furtherFormulas/savedWeights.txt', 'a')
		np.set_printoptions(threshold=np.inf, linewidth=np.inf)  # turn off summarization, line-wrapping
		outputWeightDesc = "["

		for printIndex in range(dictionaryLongitude):
			# Formatting rules applied
			outputWeightDescTemp = ""
			outputWeightDescTemp += np.array2string((dendObj[printIndex].w[:]/volt), separator=', ')
			outputWeightDescTemp = outputWeightDescTemp.replace("0.        ", "0.0")
			outputWeightDescTemp = outputWeightDescTemp.replace("0.]", "0.0]")
			outputWeightDescTemp = outputWeightDescTemp.replace(",  ", ", ")
			outputWeightDescTemp = re.sub(r"0\.\]\,", "0.0]", outputWeightDescTemp)
			outputWeightDescTemp = re.sub(r"[ ]+\]", "]", outputWeightDescTemp)
			outputWeightDescTemp = re.sub(r"[ ]+,", ",", outputWeightDescTemp)
			outputWeightDescTemp = re.sub(r"\[ ", "[", outputWeightDescTemp)
			outputWeightDescTemp = re.sub(r"([0-9]+)\]", r"\1],", outputWeightDescTemp)
			outputWeightDesc += outputWeightDescTemp
			if printIndex < (dictionaryLongitude-1): 
				outputWeightDesc += "\n"
			else:
				outputWeightDesc += "]\n"
				outputWeightDesc = outputWeightDesc.replace("],]", "]]")
				# Remove all brackets with code below because numpy.fromstring used now
				outputWeightDesc = outputWeightDesc.replace("[", "")
				outputWeightDesc = outputWeightDesc.replace("],", "")
				outputWeightDesc = outputWeightDesc.replace("]", "")	
		weightsFile.write(outputWeightDesc)
		weightsFile.close()						

	totalCorrectPercentage = (Decimal(format(testRun.truePositiveSpikeResults, '.1f'))+Decimal(format(testRun.trueNegativeSpikeResults, '.1f')))/(Decimal(format(totalSpikeIntervals, '.1f'))*Decimal(format(dictionaryLongitude, '.1f')))
	if (verbosePrint == True):
		print 'Final Weights\n'
		for printIndex in range(dictionaryLongitude):
			print dendObj[printIndex].w[:]/volt
		print 'Final Tau\n'
		for printIndex in range(dictionaryLongitude):
			print dendObj[printIndex].tau[:]/ms
		print 'Final Res\n'
		for printIndex in range(dictionaryLongitude):
			print dendObj[printIndex].r[:]/mV		
		print '\n'
		print 'testRun.firedSpikes\t',testRun.firedSpikes
		print 'testRun.assignedSpikeWindows\t',testRun.assignedSpikeWindows
		print '\n'			
		print '+++ Results +++'
		print 'Spike results: TP:\t',testRun.truePositiveSpikeResults,'\tFP:\t',testRun.falsePositiveSpikeResults,'\tTN:\t',testRun.trueNegativeSpikeResults,'\tFN:\t',testRun.falseNegativeSpikeResults
		print 'totalSpikeIntervalsTested:\t',totalSpikeIntervals,'\ttotalCharsPresented:\t',dictionaryLongitude
		print 'True positives correct percentage (TP/totalSpikeIntervalsTested):\t',Decimal(format(testRun.truePositiveSpikeResults, '.1f'))/Decimal(format(totalSpikeIntervals, '.1f')),'\t(this is the percentage of all true positves that were found)'
		print 'Total correct percentage (TP+TN/(totalSpikeIntervals*totalCharsPresented)):\t',totalCorrectPercentage
		print '+++++++++++++++'	

	if (evaluateClassifier == True):
		#print ">>>>>>>>>TrueEvalClass<<<<<<<<<<<"
		latestResultsFile = open('./furtherFormulas/latestResults.txt', 'w')
		latestResultsFile.write(str(totalCorrectPercentage))
		latestResultsFile.close()
		time.sleep(20) # Pause to ensure file write is completed before continuing
dataset/ETHPy150Open tartavull/snn-rl/furtherFormulas/testingProcesses.py/OutputEvaluationResults/original