def test_3(): objective = "read_time()" reason = "The function is not converting the time correctly, check the math" adict = {1: [1593633600, 1593637200, 1593640800, 1593644400, 1593648000]} result = RC.read_time(adict) expected = [16, 17, 18, 19, 20] assert result[1] == expected, str_form(objective, result, expected, reason)
def test_1(): objective = "read_time()" reason = "The function is not converting the time correctly, check the math" adict = {1: [1593633600]} result = RC.read_time(adict) time = DT.datetime.utcfromtimestamp(1593633600) expected = [int(f"{time:%H}") - 4] assert result[1] == expected, str_form(objective, result, expected, reason)
def test_10(): objective = "time_and_temp()" reason = "The function is not working correctly" x = RC.read_weather() time_dict = RC.read_time(x[2]) temp_dict = x[0] expected = time_and_temp(temp_dict, time_dict) result = time_and_temp(temp_dict, time_dict) print(result) assert result == expected, str_form(objective, result, expected, reason)
def test_4(): objective = "read_time()" reason = "The function is not converting the time correctly, check the math" adict = { 1: [ 1593633600, 1593637200, 1593640800, 1593644400, 1593648000, 1593651600, 1593655200, 1593658800, 1593662400, 1593666000, 1593669600, 1593673200, 1593676800, 1593680400 ] } result = RC.read_time(adict) expected = [16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5] assert result[1] == expected, str_form(objective, result, expected, reason)
def data_frame(period, data, weathertype): """ The purpose is to put the data into a single panda data frame :param: period: The period of time that we will take avg,min,max data :param: data: The weather data from the readcsv file :param: weathertype is what data you want in a data frame. Can be Temp, Pressure, Humidity :return: The data frame with all the data organized and the list of the indexes """ data_type = {'Temperature': 0, 'Pressure': 3, 'Humidity': 4} all_data = data # All of the data that is read from the read_weather function in readcsv file all_time_data = RC.read_time( all_data[2]) # Gets the time data and puts it in 24 hour format sorted_dict = sorted_data(all_data[data_type[weathertype]], all_time_data) volatility(sorted_dict, period) # The dictionary that will be used to make the data frame dataframe_dict = { 'Time': [], 'Actual': [], 'Avg': [], 'Min': [], 'Max': [] } axis_index = list() # Will become the lines in the left column for line in all_time_data: # Loops through every line from the file axis_index.append( line) # Puts the number of lines in a list. in ascending order time = all_time_data[line][ 0] # Finds the first time values from each line volatility_data = sorted_dict[time] dataframe_dict['Time'].append( time) # Adds the first time in each line into a list dataframe_dict['Actual'].append(volatility_data['Act'].pop(0)) dataframe_dict['Avg'].append(volatility_data['Avg'].pop(0)) dataframe_dict['Min'].append(volatility_data['Min'].pop(0)) dataframe_dict['Max'].append(volatility_data['Max'].pop(0)) dataframe = pd.DataFrame(dataframe_dict, axis_index) return dataframe, axis_index