Beispiel #1
0
def test_rivers_with_stations():
    stations = build_station_list()
    x = rivers_with_stations(stations)
    assert type(x) == set
    assert len(x) > 0
    for item in x:
        assert type(item) == str
Beispiel #2
0
def test_rivers_with_stations():
    # make a station list
    station_list = stationdata.build_station_list()
    rivers = geo.rivers_with_stations(station_list)

    # check number of rivers does not exceed number of stations
    assert (len(rivers) <= len(station_list))
def run():
    """Requirements for Task 1D"""

    # Build list of stations
    stations = build_station_list()

    test_case_1 = rivers_with_stations(stations)
    print(len(test_case_1))
    for i in range(10):
        print(test_case_1[i])

    test_case_2 = stations_by_river(stations)
    print(test_case_2["Thames"])
def run():
    """Requirements for Task 1D"""
    # print first 10 rivers with at least one monitoring station
    station_list = build_station_list()
    river_set = rivers_with_stations(station_list)

    print("Number of rivets with at least one monitoring station: {}".format(
        river_set))
    print(
        "First 10 rivers with monitoring stations, in alphabetical order: \n {}"
        .format(sorted(river_set)[:10]))

    # print the stations which are near specific rivers, in alphabetical order
    station_river_dict = stations_by_river(station_list)

    rivers = ['River Aire', 'River Cam', 'River Thames']
    for river in rivers:
        # make a list of station names for each river
        station_names = [s.name for s in station_river_dict[river]]
        print("Stations near {}: \n {}".format(river, sorted(station_names)))
Beispiel #5
0
from floodsystem.geo import rivers_with_stations
from floodsystem.geo import stations_by_river
from floodsystem.stationdata import build_station_list

"Part 1D Requirements"
print("Task 1D part 1")

stations = build_station_list()

river_to_station_set = sorted(rivers_with_stations(stations))
print(len(river_to_station_set))
print(river_to_station_set[:10])

print("--------------")

print("Task 1D part 2")

Task1D_2 = stations_by_river(stations)
River_Cam = sorted(Task1D_2['River Cam'])
River_Aire = sorted(Task1D_2['River Aire'])
Thames = sorted(Task1D_2['River Thames'])

print("Stations by River Aire : {}".format(River_Aire))
print("Stations by River Cam : {}".format(River_Cam))
print("Stations by River Thames : {}".format(Thames))