예제 #1
0
def test_use_trips_freq_as_persons_and_hhs_freq_no_persons_attributes(trips):
    with pytest.raises(UserWarning):
        population = load_travel_diary(trips=trips,
                                       persons_attributes=None,
                                       hhs_attributes=None,
                                       trip_freq_as_hh_freq=True,
                                       trip_freq_as_person_freq=True)
예제 #2
0
def test_read_hhs_with_missing_persons_input_and_no_trips_hid(
        trips, persons_attributes, hhs_attributes):
    trips_ = trips.drop('hid', axis=1)
    with pytest.raises(UserWarning):
        population = load_travel_diary(trips=trips_,
                                       persons_attributes=None,
                                       hhs_attributes=hhs_attributes)
예제 #3
0
def test_use_trips_freq_as_persons_freq_no_persons_attributes(trips):
    population = load_travel_diary(
        trips=trips,
        persons_attributes=None,
        trip_freq_as_person_freq=True
        )
    assert population[0][0].freq == 2
예제 #4
0
def test_agent_pid_12_not_start_and_return_home_night_worker_complex_chain_type1_intra_trip(
        test_trips, test_attributes
):
    population = load_travel_diary(test_trips, test_attributes)
    acts = [a.act for a in population.households['9'].people['12'].activities]
    print(acts)
    assert acts == ['work', 'shop', 'home', 'work']
예제 #5
0
def test_read_trips_and_persons_and_hhs_no_index(trips, persons_attributes,
                                                 hhs_attributes):
    hhs_attributes_ = hhs_attributes.reset_index()
    population = load_travel_diary(trips=trips,
                                   persons_attributes=persons_attributes,
                                   hhs_attributes=hhs_attributes_)
    assert len(population) == 3
예제 #6
0
def test_read_trips_without_seq_fail_if_out_of_order(trips):
    trips = trips.drop('seq', axis=1).iloc[::-1]
    population = load_travel_diary(
        trips=trips
    )
    with pytest.raises(PAMValidationLocationsError):
        population.validate()
예제 #7
0
def test_read_fail_with_bad_hhs_input(trips, persons_attributes, hhs_attributes):
    with pytest.raises(UserWarning):
        population = load_travel_diary(
            trips=trips,
            persons_attributes=persons_attributes,
            hhs_attributes=True
            )
예제 #8
0
def test_read_hhs_with_missing_persons_input(trips, persons_attributes, hhs_attributes):
    population = load_travel_diary(
        trips=trips,
        persons_attributes=None,
        hhs_attributes=hhs_attributes
        )
    assert len(population) == 3
예제 #9
0
def test_read_trips_and_persons_and_hhs(trips, persons_attributes, hhs_attributes):
    population = load_travel_diary(
        trips=trips,
        persons_attributes=persons_attributes,
        hhs_attributes=hhs_attributes
        )
    assert len(population) == 3
예제 #10
0
def test_read_trips_and_persons_and_hhs_from_paths():
    population = load_travel_diary(
        trips=test_trips_path,
        persons_attributes=test_attributes_path,
        hhs_attributes=test_hhs_attributes_path
        )
    assert len(population) == 23
예제 #11
0
def test_read_hh_weights_from_hhs(trips, persons_attributes, hhs_attributes):
    population = load_travel_diary(
        trips=trips,
        persons_attributes=persons_attributes,
        hhs_attributes=hhs_attributes
        )
    assert population[0].freq == 1
예제 #12
0
def test_use_trips_freq_as_persons_freq_overwrite(trips, persons_attributes):
    population = load_travel_diary(
        trips=trips,
        persons_attributes=persons_attributes,
        trip_freq_as_person_freq=True
        )
    assert population[0][0].freq == 2
예제 #13
0
def test_agent_pid_7_not_start_and_return_home_night_worker(
        test_trips, test_attributes):
    population = load_travel_diary(test_trips, test_attributes)
    person = population[4][7]
    person.print()
    print(person.home)
    acts = [a.act for a in population.households[4].people[7].activities]
    assert acts == ['work', 'home', 'work']
예제 #14
0
def test_read_hhs_with_missing_persons_input_and_no_trips_hid(trips, persons_attributes, hhs_attributes):
    trips = trips.drop('hid', axis=1)
    population = load_travel_diary(
        trips=trips,
        persons_attributes=None,
        hhs_attributes=hhs_attributes
        )
    assert len(population) == 3
    for hid, hh in population:
        assert len(hh.people) == 1
        assert isinstance(hh[hid], Person)
예제 #15
0
def test_read_trips_without_seq(trips):
    trips_ = trips.drop('seq', axis=1)
    population = load_travel_diary(
        trips=trips_
    )
    population.validate()
예제 #16
0
def test_trip_based_encoding(trips):
    population = load_travel_diary(trips=trips, tour_based=False)
    assert len(population) == 3 
예제 #17
0
def test_read_weights_from_trips(trips):
    population = load_travel_diary(trips=trips)
    assert population[1].freq == 6
    assert population[1][2].freq == 6
예제 #18
0
def test_read_trips_from_path():
    population = load_travel_diary(trips=test_trips_path)
    assert len(population) == 23
예제 #19
0
def test_trips_read_fail_with_no_pid_field(trips):
    trips_no_pid = trips.drop('pid', axis=1)
    with pytest.raises(UserWarning):
        population = load_travel_diary(trips=trips_no_pid)
예제 #20
0
def test_read_fail_with_no_trips_input():
    with pytest.raises(UserWarning):
        population = load_travel_diary(trips=None)
예제 #21
0
def test_read_trips_only(trips):
    print(trips.describe())
    print(trips.dtypes)
    population = load_travel_diary(trips=trips)
    assert len(population) == 3
예제 #22
0
def test_agent_pid_14_not_start_from_home_impossible_chain_type1_intra_trip(
        test_trips, test_attributes):
    population = load_travel_diary(test_trips, test_attributes)
    acts = [a.act for a in population.households[11].people[14].activities]
    assert acts == ['work', 'shop', 'home']
예제 #23
0
def test_read_trips_with_seq(trips):
    population = load_travel_diary(
        trips=trips
    )
    population.validate()
예제 #24
0
def test_agent_pid_5_not_start_from_home(test_trips, test_attributes):
    population = load_travel_diary(test_trips, test_attributes)
    acts = [a.act for a in population.households[2].people[5].activities]
    assert acts == ['work', 'home']
예제 #25
0
def test_extra_person_stays_at_home(trips, extra_persons_attributes):
    population = load_travel_diary(trips=trips, persons_attributes=extra_persons_attributes)
    assert len(population[1][3].plan) == 1
    assert population[1][3].plan.day[0].act == "home"
예제 #26
0
def test_agent_pid_6_not_return_home(test_trips, test_attributes):
    population = load_travel_diary(test_trips, test_attributes)
    acts = [a.act for a in population.households[3].people[6].activities]
    assert acts == ['home', 'work']
예제 #27
0
def test_persons_read_fail_with_no_pid_field(trips, persons_attributes):
    persons_no_pid = persons_attributes.reset_index().drop('pid', axis=1)
    with pytest.raises(UserWarning):
        population = load_travel_diary(trips=trips, persons_attributes=persons_no_pid)
예제 #28
0
def test_agent_pid_20_not_start_and_return_home_night_worker_complex_chain_type2_intra_trip_not_work(
        test_trips, test_attributes):
    population = load_travel_diary(test_trips, test_attributes)
    acts = [a.act for a in population.households[17].people[20].activities]
    assert acts == ['escort', 'shop', 'home', 'escort']
예제 #29
0
def test_act_based_encoding(activity_encoded_trips):
    population = load_travel_diary(trips=activity_encoded_trips)
    assert len(population) == 3
예제 #30
0
def test_persons_read_with_pid_not_as_index(trips, persons_attributes):
    persons_ = persons_attributes.reset_index()
    population = load_travel_diary(trips=trips, persons_attributes=persons_)
    assert len(population) == 3