PEATSA/Core/Tests/UnitTests/TestMatrix.py
def testReadCSV(self):
	
		'''Tests if a matrix can be properly initialised from a csv file'''
	
		#Test can read csv files produce by the class itself
		string = self.matrix.csvRepresentation()
		file = open('temp', 'w')
		file.write(string)
		file.close()
		
		matrix = Matrix.matrixFromCSVFile('temp')
		
		self.assertEqual(matrix, self.matrix)
		os.remove('temp')
		
		#Test initialisation for a csv file not in the same format
		#as the one created by the Matrix class
		file = open('temp', 'w')
		file.write(testCSVString)
		file.close()
		
		matrix = Matrix.matrixFromCSVFile('temp')
		self.assertEqual(matrix, self.matrix)
		
		#Test it works when told not to read header
		file = open('temp', 'w')
		file.write(testCSVString2)
		file.close()
		
		matrix = Matrix.matrixFromCSVFile(filename='temp', readHeaders=False)
		matrix.setColumnHeaders(["Header1", "Header2"])
		self.assertEqual(matrix, self.matrix)
		
		#Clean up
		os.remove('temp')
Tests if a matrix can be properly initialised from a csv file
Tests if a matrix can be properly initialised from a csv file
Tests if a matrix can be properly initialised from a csv file
def testReadCSV(self):
		string = self.matrix.csvRepresentation()
		file = open('temp', 'w')
		file.write(string)
		file.close()
		matrix = Matrix.matrixFromCSVFile('temp')
		self.assertEqual(matrix, self.matrix)
		os.remove('temp')
		file = open('temp', 'w')
		file.write(testCSVString)
		file.close()
		matrix = Matrix.matrixFromCSVFile('temp')
		self.assertEqual(matrix, self.matrix)
		file = open('temp', 'w')
		file.write(testCSVString2)
		file.close()
		matrix = Matrix.matrixFromCSVFile(filename='temp', readHeaders=False)
		matrix.setColumnHeaders(["Header1", "Header2"])
		self.assertEqual(matrix, self.matrix)
		os.remove('temp')
def testReadCSV ( self ) : string = self . matrix . csvRepresentation ( ) file = open ( 'temp' , 'w' ) file . write ( string ) file . close ( ) matrix = Matrix . matrixFromCSVFile ( 'temp' ) self . assertEqual ( matrix , self . matrix ) os . remove ( 'temp' ) file = open ( 'temp' , 'w' ) file . write ( testCSVString ) file . close ( ) matrix = Matrix . matrixFromCSVFile ( 'temp' ) self . assertEqual ( matrix , self . matrix ) file = open ( 'temp' , 'w' ) file . write ( testCSVString2 ) file . close ( ) matrix = Matrix . matrixFromCSVFile ( filename = 'temp' , readHeaders = False ) matrix . setColumnHeaders ( [ "Header1" , "Header2" ] ) self . assertEqual ( matrix , self . matrix ) os . remove ( 'temp' )
Tests if a matrix can be properly initialised from a csv file
Tests if a matrix can be properly initialised from a csv file
'''Tests if a matrix can be properly initialised from a csv file''' #Test can read csv files produce by the class itself #Test initialisation for a csv file not in the same format #as the one created by the Matrix class #Test it works when told not to read header #Clean up
self