Skip to content

Commit

Permalink
Accept zero number_of_people_per_household
Browse files Browse the repository at this point in the history
  • Loading branch information
invisibleroads committed Feb 24, 2017
1 parent 8113038 commit 59627af
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions infrastructure_planning/demography/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from pandas import Series

from ..macros import get_final_value
from ..macros import get_final_value, make_zero_by_year


def estimate_population_profile(population_by_year):
return {
'final_population': get_final_value(population_by_year),
'zero_by_year': Series(0, index=population_by_year.index),
'zero_by_year': make_zero_by_year(population_by_year),
}
13 changes: 8 additions & 5 deletions infrastructure_planning/electricity/consumption/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
from pandas import DataFrame, Series, concat, isnull, merge

from ...growth import get_default_slope, get_future_years
from ...growth.interpolated import get_interpolated_spline_extrapolated_linear_function as get_estimate_electricity_consumption # noqa
from ...macros import get_final_value
from ...growth.interpolated import (
get_interpolated_spline_extrapolated_linear_function as
get_estimate_electricity_consumption)
from ...macros import get_final_value, make_zero_by_year


def estimate_consumption_from_connection_type(
Expand All @@ -14,10 +16,11 @@ def estimate_consumption_from_connection_type(
if there is a local override for household_count.
"""
d = {}
connection_count_by_year = Series(0, index=population_by_year.index)
consumption_by_year = Series(0, index=population_by_year.index)
connection_count_by_year = make_zero_by_year(population_by_year)
consumption_by_year = make_zero_by_year(population_by_year)
estimated_household_connection_count_by_year = divide_safely(
population_by_year, number_of_people_per_household, 0)
population_by_year, number_of_people_per_household,
make_zero_by_year(population_by_year))
for row_index, row in connection_type_table.iterrows():
connection_type = row['connection_type']
count_by_year = _get_connection_count_by_year(
Expand Down
4 changes: 4 additions & 0 deletions infrastructure_planning/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ def get_final_value(value_by_year):
return value_by_year.ix[sorted(value_by_year.index)[-1]]


def make_zero_by_year(value_by_year):
return Series(0, index=value_by_year.index)


def get_graph_from_table(table):
graph = InfrastructureGraph()
for index, row in table.iterrows():
Expand Down

0 comments on commit 59627af

Please sign in to comment.