def prepare_loaded_data(self, file_name): """ Przygotowuje i wczytuje dane z pliku :param file_name: plik z danymi :return: """ #utworzenie bufora buff = Buffer() data = CsvReader.read_from_file(file_name, 1) #zmiana czasu data = DataOperation.change_time_relative(data) #zmiana wysokosci na metry data = DataOperation.change_altitude_cm_m(data) #stworzenie zapisywacza saver = FileSaver("saved_data/dane.txt") #kazda linijke z pliku csv buforujemy osobno for d in data: buff.set_data(d) buffered_data = buff.get_data() #sprawdzamy czy kazda linijka jest poprawnie zapisana if InputValidator.input_val(buffered_data): #zapisujemy kazda linijke do nowego pliku saver.save_data(buffered_data) #odczyt danych z pliku csv i wizualizacja r_data = CsvReader.read_from_file(saver.get_file_name()) #tworzymy wizualizator, drugi parametr do interwal czasowy self.visualizer = PlotCreator(r_data, 1) self.data_loaded = True print "Dane zaladowane"
def test_square_method_calculator(self): test_data = CsvReader('/src/Unit Test Square.csv').data #pprint(test_data) for row in test_data: self.assertEqual(self.calculator.sqr(row['Value 1']), float(row['Result'])) self.assertEqual(self.calculator.result, float(row['Result'])) test_data.clear()
def test_subtraction_method_calculator(self): test_data = CsvReader('/src/Unit Test Subtraction.csv').data #pprint(test_data) for row in test_data: self.assertEqual( self.calculator.subtract(row['Value 1'], row['Value 2']), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result'])) test_data.clear()
def test_division_method_calculator(self): test_data = CsvReader('/src/Unit Test Division.csv').data #pprint(test_data) for row in test_data: self.assertEqual( self.calculator.divide(row['Value 1'], row['Value 2']), float(row['Result'])) self.assertEqual(self.calculator.result, float(row['Result'])) test_data.clear()
def test_multiplication(self): calculator = Calculator() testData = CsvReader('src/Unit Test Multiplication.csv').data for row in testData: self.assertEqual( calculator.multiply(int(row['Value 1']), int(row['Value 2'])), int(row['Result']))
def test_add_method_calculator(self): test_data = CsvReader('/src/Unit Test Addition.csv').data for row in test_data: self.assertEqual( self.calculator.add(row['Value 1'], row['Value 2']), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_multiply_method_calculator(self): test_data = CsvReader('/src/Unit Test Multiplication.csv').data for row in test_data: self.assertEqual( self.calculator.multiply(row['Value 1'], row['Value 2']), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_square(self): test_data = CsvReader('./src/test_square.csv').data pprint(test_data) for row in test_data: self.assertEqual(self.calculator.squaring(int(row['Value 1'])), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_addition(self): test_data = CsvReader('./src/test_addition.csv').data for row in test_data: self.assertEqual( self.calculator.add(int(row['Value 1']), int(row['Value 2'])), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_addition(self): calculator = Calculator() testData = CsvReader('src/Unit Test Addition.csv' ).data #.return_data_as_objects('addition') for row in testData: self.assertEqual( calculator.add(int(row['Value 1']), int(row['Value 2'])), int(row['Result']))
def test_sqrroot_method_calculator(self): test_data = CsvReader('/src/Unit Test Square Root.csv').data for row in test_data: self.assertAlmostEqual( self.calculator.squareroot(row['Value 1'], ), float(row['Result'])) self.assertAlmostEqual(self.calculator.result, float(row['Result']))
def test_subtraction(self): calculator = Calculator() testData = CsvReader('src/Unit Test Subtraction.csv').data for row in testData: #print('Value 1:', row['Value 1'], 'Value 2', row['Value 2'], 'Result', row['Result'], 'Answer', calculator.subtract(int(row['Value 1']), int(row['Value 2']))) self.assertEqual( calculator.subtract(int(row['Value 1']), int(row['Value 2'])), int(row['Result']))
def test_multiply(self): test_data = CsvReader('./src/test_multiplication.csv').data pprint(test_data) for row in test_data: self.assertEqual( self.calculator.multiply(int(row['Value 1']), int(row['Value 2'])), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_square_root(self): test_data = CsvReader('./src/test_square_root.csv').data pprint(test_data) for row in test_data: self.assertAlmostEqual(self.calculator.sqrt(int(row['Value 1'])), float(row['Result']), places=4) self.assertAlmostEqual(self.calculator.result, float(row['Result']), places=4)
def test_squarerooted(self): calculator = Calculator() testData = CsvReader('src/Unit Test Square Root.csv').data for row in testData: decimal_at = row['Result'].find('.') precision = len(row['Result']) - decimal_at - 1 if decimal_at == -1: precision = 0 self.assertEqual( round(calculator.squareroot(int(row['Value 1'])), precision), round(float(row['Result']), precision))
from Buffer import Buffer from CSVReader import CsvReader from InputValidator import InputValidator from DataOperation import DataOperation from PlotCreator import PlotCreator from UI import MainWindow import sys #przeplyw danych csvReader -> podzial na wiersze -> buffer -> InputValidation - >fileSaver #utworzenie bufora buff = Buffer() file_name = raw_input("Podaj nazwe pliku z danymi w formacie csv \n") #wczytanie danych z pliku csv data = CsvReader.read_from_file(file_name, 1) #zmiana czasu data = DataOperation.change_time_relative(data) #zmiana wysokosci na metry data = DataOperation.change_altitude_cm_m(data) #stworzenie zapisywacza saver = FileSaver("saved_data/dane.txt") #kazda linijke z pliku csv buforujemy osobno for d in data: buff.set_data(d) buffered_data = buff.get_data() #sprawdzamy czy kazda linijka jest poprawnie zapisana if InputValidator.input_val(buffered_data): #zapisujemy kazda linijke do nowego pliku saver.save_data(buffered_data)
def test_sqr_method_calculator(self): test_data = CsvReader('/src/Unit Test Square.csv').data for row in test_data: self.assertEqual(self.calculator.square(row['Value 1'], ), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result']))
def test_squared(self): calculator = Calculator() testData = CsvReader('src/Unit Test Square.csv').data for row in testData: self.assertEqual(calculator.square(int(row['Value 1'])), int(row['Result']))