#24 Create project structure for unit tests

Refactor project's structure
closes #24
This commit is contained in:
Marc-Antoine Lafreniere
2019-02-05 13:45:15 -05:00
parent b6bf4d9291
commit 9ef1058012
14 changed files with 5783 additions and 5776 deletions

View File

View File

@@ -0,0 +1,24 @@
import math
"""
Reformat the file receive by the binary to ascii converter to have matrix with the right width and height
"""
def formatPbm(pbmFile):
dimensionLineIndex = 2
completeFile = []
lines = open(pbmFile, 'r').readlines()
width, height = (int(val) for val in lines[dimensionLineIndex].split())
for line in lines[dimensionLineIndex+1:]:
for val in line.split():
completeFile += [int(val)]
formattedFile = [[0 for i in range(width)] for j in range(height)]
for index, value in enumerate(completeFile):
formattedFile[math.floor(index/width)][index%width] = value
return formattedFile

View File

@@ -0,0 +1,11 @@
"""
Save a two dimension array in a file
"""
def matrixToFile(matrix, fileName):
with open(fileName, 'w') as f:
for x in matrix:
for y in x:
f.write('%s ' % y )
f.write('\n')