Skip to content

Commit

Permalink
Simples print statements across cropping
Browse files Browse the repository at this point in the history
  • Loading branch information
gac55 committed Sep 5, 2024
1 parent c8bff76 commit d388e82
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/pam/operations/cropping.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,40 @@ def simplify_population(
) -> None:
"""Simplify external plans across a population."""
# simplify plans
pre_stats = population.stats
for hid, pid, person in population.people():
simplify_external_plans(person.plan, boundary, snap_to_boundary, rename_external_activities)

# remove empty person-plans and households
remove_persons = []

for hid, pid, person in population.people():
if len(person.plan) == 1 and person.plan.day[0].act == "external":
remove_persons.append((hid, pid))
for hid, pid in remove_persons:
del population[hid].people[pid]

print("After simplification",population.stats)
# print("List of persons to remove:", remove_persons)
print(len(remove_persons), " persons to be removed")

remove_hhs = [
hid for hid in population.households if len(population.households[hid].people) == 0
]

print(len(remove_hhs), "households to be removed")

for hid in remove_hhs:
del population.households[hid]

gc_dict = {"remove_persons": remove_persons,
"remove_hhs": remove_hhs,
"population_stats_before": pre_stats,
"population_stats_after": population.stats,
}
# gc_dict.to_json(".json")

print(population.stats)


def simplify_external_plans(
Expand Down

0 comments on commit d388e82

Please sign in to comment.