def validationSizeContainer(self): string = self.readBuffer.split(' ') for x in string: if (len(x) == 0): errorExit("Invalid space") if (len(x) > 2): errorExit("Invalid container too much symbol")
def convertMileage(s): mileage = 0 try: isInt(s) mileage = int(s) if (mileage < 0): sys.exit(-1) except: errorExit("Invalid digitals mileage") return (mileage)
def convertMileage(s, dataList): mileage = 0 try: isInt(s) mileage = int(s) if (mileage < 0): sys.exit(-1) except: errorExit("Invalid digitals mileage") mileage = minMaxScaling(mileage, dataList[1][1], dataList[1][0]) return (mileage)
def convertData(readBuffer): res = readBuffer.split("\n") listRes = list() for x in res: tmp = x.split(",") try: listRes.append([float(tmp[0]), float(tmp[1])]) except: pass if (len(listRes)) < 2: errorExit("Error data") return listRes
print( " -f. This is read from file.\n Example: python main.py -i fileName -g" ) print( " -g. This is color print Solution.\n Example: python main.py -i 25 -g" ) print( " -gt. This is without color.\n Example: python main.py -f fileName -gt" ) print( " -wc. -wc. This is without print Solution. Only steps move\n Example: python main.py -f fileName -wc" ) sys.exit(-1) if (len(sys.argv) != 4 and len(sys.argv) != 2): errorExit(stringUsage) if (len(sys.argv) == 4 and ((sys.argv[1] != "-f" and sys.argv[1] != "-i") or (sys.argv[3] != "-g" and sys.argv[3] != "-gt" and sys.argv[3] != "-wc"))): errorExit(stringUsage) if ((len(sys.argv) == 4) and sys.argv[1] == "-f"): readBuffer = readFile(sys.argv[2]) validationManager = ValidationManager(readBuffer) validationManager.run() elif (len(sys.argv) == 2): readBuffer = sys.argv[1] validationManager = ValidationManager(sys.argv[1]) validationManager.run() mixManager = MixManager() moveList = list()
import sys from math import * import math from src.readFile import readFile from src.convertData import convertData from src.errorExit import * from src.calcEstimatedPrice import * from src.writeFile import * if (len(sys.argv) != 2): errorExit("Usage: python main.py fileData") def min_max_scaling(data): X = [_[0] for _ in data] y = [_[1] for _ in data] minX = min(X) maxX = max(X) for i in range(len(X)): data[i][0] = (X[i] - minX) / (maxX - minX) return data data = convertData(readFile(sys.argv[1])) learningRate = 0.1 teta0 = 0.0 teta1 = 0.0 m = float(len(data)) data = min_max_scaling(data) print(data) cnt = 0
import sys from src.readFile import * from src.errorExit import * from src.convertData import * from src.ft_math.calcEstimatedPrice import * from src.ft_math.minMaxScaling import * from src.isInt import * def convertMileage(s, dataList): mileage = 0 try: isInt(s) mileage = int(s) if (mileage < 0): sys.exit(-1) except: errorExit("Invalid digitals mileage") mileage = minMaxScaling(mileage, dataList[1][1], dataList[1][0]) return (mileage) if (len(sys.argv) != 2): errorExit("Usage: python mainFirstProgram mileage") dataList = convertData(readFile("tetas.csv")) mileage = convertMileage(sys.argv[1], dataList) print(calcEstimatedPrice(mileage, float(dataList[0][0]), float(dataList[0][1])))
def validationSizeSymbol(self): string = self.readBuffer.split(' ') for x in string: match = re.search(r'[A-Z]+', x) if (match == None): errorExit("Need one char")
def validationSymbol(self): string = self.readBuffer.split(' ') for x in string: match = re.search(r'[^FBRLUD2\']', x) if (match): errorExit("Unknow symbol")
def validationLen(self): string = self.readBuffer.split('\n') if (len(string) != 1): errorExit("need one line")