def test_inconsistent_typical_range_stations(): # Create a station s_id = "test-s-id" m_id = "test-m-id" label = "some station" coord = (-2.0, 4.0) trange = (-2.3, 3.4445) river = "River X" town = "My Town" s = MonitoringStation(s_id, m_id, label, coord, trange, river, town) Example_list =[] Example_list.append(s) Test_List = inconsistent_typical_range_stations(Example_list) assert Test_List == [] #create inconsistent typical range for testing trange = (3.4445, -2.3) t = MonitoringStation(s_id, m_id, label, coord, trange, river, town) Example_list =[] Example_list.append(t) Test_List = inconsistent_typical_range_stations(Example_list) assert Test_List == ["some station"] #Create NoneType data to test trange = None u = MonitoringStation(s_id, m_id, label, coord, trange, river, town) Example_list =[] Example_list.append(u) Test_List = inconsistent_typical_range_stations(Example_list) assert Test_List == ["some station"]
def test_inconsistent_typical_range_stations(): #create some station data new_monitoring_station = MonitoringStation(None, None, None, None, [5, 0], None, None) new_monitoring_station2 = MonitoringStation(None, None, None, None, [0, 5], None, None) new_monitoring_station3 = MonitoringStation(None, None, None, None, None, None, None) new_monitoring_station4 = MonitoringStation(None, None, None, None, [5, 5], None, None) #create an empty list dummy_data = [] #add the station data to a list dummy_data.append(new_monitoring_station) dummy_data.append(new_monitoring_station2) dummy_data.append(new_monitoring_station3) dummy_data.append(new_monitoring_station4) print(inconsistent_typical_range_stations(dummy_data)) assert inconsistent_typical_range_stations(dummy_data) == [ new_monitoring_station, new_monitoring_station3 ] #check if inconsistent_typical_range_stations(dummy_data) print("it works too")
def test_inconsistent_typical_stations(): test_station1 = station.MonitoringStation(station_id="test_station_id", measure_id="test_measure_id", label="test_label", coord=(52.845991, -0.100848), town="Cambridge", river="River Cam", typical_range=None) test_station2 = station.MonitoringStation(station_id="test_station_id", measure_id="test_measure_id", label="test_label", coord=(52.845991, -0.100848), town="Cambridge", river="River Cam", typical_range=(1.2, 0.8)) test_station3 = station.MonitoringStation(station_id="test_station_id", measure_id="test_measure_id", label="test_label", coord=(52.845991, -0.100848), town="Cambridge", river="River Cam", typical_range=(0.8, 1.2)) stations = [test_station1, test_station2, test_station3] assert set([test_station1, test_station2]) == set( station.inconsistent_typical_range_stations(stations))
def test_inconsistent_typical_range_stations(): stations = build_station_list() x = inconsistent_typical_range_stations(stations) assert type(x) == list assert len(x) > 0 for item in x: assert type(item) == str
def test_inconsistent_typical_range_stations_returns_a_list_of_all_inconsistent_stations( ): stations = [] s_id = "test-s-id" m_id = "test-m-id" label = "some station" coord = (-2.0, 4.0) river = "River X" town = "My Town" trange = (-2.3, 3.4445) stations.append( MonitoringStation(s_id, m_id, label, coord, trange, river, town)) trange = (2.3, -3.4445) stations.append( MonitoringStation(s_id, m_id, label, coord, trange, river, town)) trange = None stations.append( MonitoringStation(s_id, m_id, label, coord, trange, river, town)) actual_inconsistent_stations = inconsistent_typical_range_stations( stations) expected_inconsistent_stations = [stations[1], stations[2]] assert expected_inconsistent_stations == actual_inconsistent_stations
def test_inconsistent_typical_range_stations(): """Checks for inconsistencies in the reported typical ranges of the monitoring stations""" stations = build_station_list() x = inconsistent_typical_range_stations(stations) y = sorted(x) assert 'Addlestone' in y
def test_inconsistent_typical_range_stations(): stations = build_station_list() r2 = inconsistent_typical_range_stations(stations) for i in stations: for j in r2: if i.name == j: assert i.typical_range == None or i.typical_range[ 1] - i.typical_range[0] < 0
def run(): stations = build_station_list() inconsistant_stations = inconsistent_typical_range_stations(stations) inconsistant_stations = sorted( [station.name for station in inconsistant_stations]) print(inconsistant_stations)
def run(): """Requirements for Task 1F""" # Build list of stations stations = build_station_list() # Print names of inconsistent stations print(sorted([s.name for s in inconsistent_typical_range_stations(stations)]))
def test_inconsistent_typical_range_stations(): """test to see if this function return stations with inconsistant ranges""" stations = generate_test_station() inconst_stations = inconsistent_typical_range_stations(stations) for station in inconst_stations: assert station.typical_range_consistent() is False assert station.relative_water_level() is None
def run(): """Requirement for Task 1F""" stations = build_station_list() # Build set of rivers inconsistent_stations = inconsistent_typical_range_stations(stations) sorted_inconsistent_stations = sorted(inconsistent_stations) print(sorted_inconsistent_stations)
def run(): """Requirements for Task 1F""" # Build list of stations stations = build_station_list() x = inconsistent_typical_range_stations(stations) y = [] for station in x: y.append(station.name) print(y)
def run(): stations = build_station_list() inconsistent_stations = inconsistent_typical_range_stations(stations) station_names = [] for station in inconsistent_stations: station_names.append(station.name) station_names.sort() print(station_names)
def run(): """Requirements for Task 1F""" # Build list of inconsistent stations stations = build_station_list() inconsistent_stations = inconsistent_typical_range_stations(stations) inconsistent_stations_names = [] # Creates new list to store inconsistent station's names for i in range(len(inconsistent_stations)): # Extracts names and appends to list inconsistent_stations_names.append(inconsistent_stations[i].name) inconsistent_stations_names.sort() # Sorts list print(inconsistent_stations_names) # Prints Test list
def run(): '''Testing for inconsistent_typical_range_stations ''' # generate stations list stations = build_station_list() # get consistent station names output = station.inconsistent_typical_range_stations(stations) print(output) return output
def test_inconsistent_typical_range_stations(): # Build list of stations stations = build_station_list() inconsistent = inconsistent_typical_range_stations(stations) assert inconsistent == [ 'Addlestone', 'Airmyn', 'Allerford', 'Blacktoft', 'Braunton', 'Brentford', 'Broomfleet Weighton Lock', 'East Hull Hedon Road', 'Fleetwood', 'Goole', 'Hedon Thorn Road Bridge', 'Hedon Westlands Drain', 'Hull Barrier Victoria Pier', 'Hull High Flaggs, Lincoln Street', "King's Lynn", 'Littlehampton', 'Paull', 'Salt end', 'Silloth Docks', 'Sindlesham Mill', 'Stone Creek', 'Templers Road', 'Topsham', 'Totnes', 'Truro Harbour', 'Wilfholme PS', 'Wilfholme PS Hull Level' ]
def run(): """Requirements for Task 1F """ print("*** Task 1F: CUED Part IA Flood Warning System ***") # Build list of stations stations = build_station_list() # Build list of stations with inconsistent data print( "The following are inconsistent stations, whereby the data received from DEFRA is erroneous such that the typical high flow is less than the low flow, or the data provided was not in the form a tuple:" ) print((inconsistent_typical_range_stations(stations)))
def test_inconsistent_typical_range_stations(): #Create station with inconsistent range s_id = "test-s-id" m_id = "test-m-id" label = "some station" coord = (6.0, 4.0) trange = None river = "River X" town = "My Town" s = MonitoringStation(s_id, m_id, label, coord, trange, river, town) trange = (-1, 2) s1 = MonitoringStation(s_id, m_id, label, coord, trange, river, town) stations = [s, s1] assert len(station.inconsistent_typical_range_stations(stations)) == 1
def test_inconsistent_typical_range_stations(): s1 = MonitoringStation("station_1", "measure_id", "station_1", (-2.0, 4.0), None, "river", "town") s2 = MonitoringStation("station_2", "measure_id", "station_2", (-2.0, 4.0), (0.432, 3.23), "river", "town") s3 = MonitoringStation("station_3", "measure_id", "station_3", (-2.0, 4.0), (0.432, 2.43), "river", "town") s4 = MonitoringStation("station_4", "measure_id", "station_4", (-2.0, 4.0), (4.432, 3.43), "river", "town") stations = [s1, s2, s3, s4] assert inconsistent_typical_range_stations(stations) == [ "station_1", "station_4" ]
def run(): """Requirement for Task 1F""" #Initialise variables data = build_station_list() ID = [] #Get list of stations with inconsistent typical range data ls = inconsistent_typical_range_stations(data) #Add names of stations with inconsistent data for station in ls: ID.append(station.name) #Sort alphabetically ID.sort() print(ID)
def run(): #builds a list of all stations stations = stationdata.build_station_list() #use_cache=True argument? # with inconsistent typical range data #gets inconsistent_data inconsistent_data = station.inconsistent_typical_range_stations(stations) #list with objectums where typical range is bad inconsistent_station_names = [] #empty list for i in inconsistent_data: inconsistent_station_names.append(i.name) #filling up the list with the names of inconst data #orders the list of names of inconst stations alphabetically order_inconsistent = sorted(inconsistent_station_names) print(order_inconsistent)
def test_station_2(): disagree = 0 # Build list of stations stations = build_station_list() # Build list of stations with inconsistent data bad_stations = [] bad_stations = inconsistent_typical_range_stations(stations) for station in stations: if station.name in bad_stations: if isinstance(station.typical_range, tuple): if station.typical_range[1] - station.typical_range[0] >= 0: disagree += 1 else: pass else: pass else: pass assert disagree == 0
def run(): """Requirements for Task1F""" print(sorted([station.name for station in inconsistent_typical_range_stations(build_station_list())]))
def run(): # Build list of stations stations = build_station_list() print (inconsistent_typical_range_stations(stations))
def test_inconsistent_typical_range_stations(): k = inconsistent_typical_range_stations(stations) for i in k: assert type(i) == MonitoringStation assert type(k) == list
from floodsystem.station import inconsistent_typical_range_stations from floodsystem.stationdata import build_station_list from floodsystem.station import MonitoringStation print("Task 1F Requirements") print("----------------") print(sorted(inconsistent_typical_range_stations(build_station_list())))
def test_inconsistent_typical_range_stations(): stations = build_station_list() for a in inconsistent_typical_range_stations(stations): #check that each entry in the list has inconsistent range assert a.typical_range == None or a.typical_range[0]>a.typical_range[1]
def test_inconsistent_typical_range_stations(): stations = gen_stations() inconsistent_stations = inconsistent_typical_range_stations(stations) assert inconsistent_stations == [stations[1], stations[3]]
from floodsystem.station import inconsistent_typical_range_stations from floodsystem.stationdata import build_station_list stations = build_station_list() a = inconsistent_typical_range_stations(stations) print(a)
# -*- coding: utf-8 -*- """ Created on Sat Feb 4 00:46:15 2017 @author: hz324 """ from floodsystem.stationdata import build_station_list from floodsystem.station import inconsistent_typical_range_stations stations = build_station_list() list_of_inconsistency = inconsistent_typical_range_stations(stations) print(list_of_inconsistency)