import plot_temperature dir(plot_temperature) cat mosquito_data_A1.csv def test_output_read_csv_file(): year, temperature, rainfall, mosquitos = plot_temperature.read_csv_file('mosquito_data_A1.csv') year_key = [2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010] for yr_guess, yr_solution in zip(year, year_key): assert yr_guess == yr_solution, 'year doesn\'t match key' test_output_read_csv_file() def test_output_read_csv_file(): year, temperature, rainfall, mosquitos = plot_temperature.read_csv_file('mosquito_data_A1.csv') assert (year == np.array([2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010])).all() test_output_read_csv_file() def test_convert_fahrenheit_to_celsius(): temp_c = plot_temperature.convert_fahrenheit_to_celsius(32) assert temp_c == 0, '32F != 0C' test_convert_fahrenheit_to_celsius() def read_csv_file(filename): ''' This code will read in a CSV file of year, temperature, rainfall, and number of mosquitos and return 4 arrays, one for each column ''' assert type(filename) is str, 'filename must be a string' year, temperature, rainfall, mosquitos = np.genfromtxt(filename, skiprows = 1, delimiter = ',', unpack = True) return year, temperature, rainfall, mosquitos read_csv_file('mosquito_data_A1.csv') def read_csv_file(filename): ''' This code will read in a CSV file of year, temperature, rainfall, and number of mosquitos and return 4 arrays, one for each column ''' assert isinstance(filename, str), 'filename must be a string' year, temperature, rainfall, mosquitos = np.genfromtxt(filename, skiprows = 1, delimiter = ',', unpack = True) return year, temperature, rainfall, mosquitos read_csv_file('mosquito_data_A1.csv') read_csv_file(4) def convert_fahrenheit_to_celsius(temp_in_f): ''' This code will convert an array of tempertures from fahrenheit to celsius ''' assert isinstance(temp_in_f, float) or isinstance(temp_in_f, int), 'temperature must be an int or float' temp_in_c = (temp_in_f - 32) * 5 / 9.0 return temp_in_c convert_fahrenheit_to_celsius(4) convert_fahrenheit_to_celsius(10.) convert_fahrenheit_to_celsius('a')