From bf854470a997a4a27921fe020f9c39c9cefe135c Mon Sep 17 00:00:00 2001 From: chenzheng06 Date: Wed, 26 Apr 2017 16:56:15 -0400 Subject: [PATCH 1/3] Remove analysis_date from form_income_statement_hist func --- bpfin/financials/income_statement_form_hist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bpfin/financials/income_statement_form_hist.py b/bpfin/financials/income_statement_form_hist.py index 65ba995..4ddd4d9 100644 --- a/bpfin/financials/income_statement_form_hist.py +++ b/bpfin/financials/income_statement_form_hist.py @@ -41,7 +41,7 @@ def income_statement_character(income_statement_hist): return result_dict -def form_income_statement_hist(raw_income_input, bill_overview_organized, analysis_date): +def form_income_statement_hist(raw_income_input, bill_overview_organized): """ form income statement table with raw inputs from UI, and organized bill_overview. NO projection Args: raw_income_input (dictionary): dictionary of dictionary. raw inputs for income statement for available years -- GitLab From cffcf09518855d08587599f5aa794c56effad19a Mon Sep 17 00:00:00 2001 From: chenzheng06 Date: Wed, 26 Apr 2017 18:45:57 -0400 Subject: [PATCH 2/3] Remove comment from income_statement_form_hist. Remove print from income_statement_next --- bpfin/financials/income_statement_form_hist.py | 1 - bpfin/financials/income_statement_next.py | 1 - 2 files changed, 2 deletions(-) diff --git a/bpfin/financials/income_statement_form_hist.py b/bpfin/financials/income_statement_form_hist.py index 4ddd4d9..2cfa502 100644 --- a/bpfin/financials/income_statement_form_hist.py +++ b/bpfin/financials/income_statement_form_hist.py @@ -46,7 +46,6 @@ def form_income_statement_hist(raw_income_input, bill_overview_organized): Args: raw_income_input (dictionary): dictionary of dictionary. raw inputs for income statement for available years bill_overview_organized (dictionary): dict of dict, 4 utility types, with blank charge filled with average - analysis_date (dictionary): proforma's starting date and the years of proforma Returns: Dictionary: dict of dict, full income statement for available years diff --git a/bpfin/financials/income_statement_next.py b/bpfin/financials/income_statement_next.py index d46c4ab..7b15349 100644 --- a/bpfin/financials/income_statement_next.py +++ b/bpfin/financials/income_statement_next.py @@ -32,7 +32,6 @@ def income_statement_next(income_statement_hist, bill_overview_organized, growth income_next.assign_next(characters, bill_overview_organized) result_dict = fl.convert_income_statement_class(income_next) - print(result_dict) return result_dict # def income_statement_proj_input(income_statement_full, bill_overview_organized, growth_rate_flag): -- GitLab From bfdb38ef5568d247830c35e565a46bb7c0f8daf0 Mon Sep 17 00:00:00 2001 From: chenzheng06 Date: Wed, 26 Apr 2017 22:12:53 -0400 Subject: [PATCH 3/3] Update organize_bill_overview, and its test file --- bpfin/financials/financial_lib.py | 16 +++++++++++++--- .../test_income_statement_form_hist.py | 4 +--- bpfin/tests/testdata/sample_data.py | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bpfin/financials/financial_lib.py b/bpfin/financials/financial_lib.py index dcf1358..d3ee319 100644 --- a/bpfin/financials/financial_lib.py +++ b/bpfin/financials/financial_lib.py @@ -82,9 +82,17 @@ def organize_bill_overview(bill_overview, analysis_date): for i in range(4): if bill_dict[i + 1][1] is False: - average_bill_dict[i + 1] = float( - sum(bill_dict[i + 1][0][year] for year in bill_dict[i + 1][ - 0])) / len(bill_dict[i + 1][0]) + sum_bill = 0 + year_number = 0 + for year in bill_dict[i + 1][0]: + if bill_dict[i + 1][0][year] != 0: + sum_bill += bill_dict[i + 1][0][year] + year_number += 1 + if year_number != 0: + average_bill_dict[i + 1] = float(sum_bill) / year_number + else: + average_bill_dict[i + 1] = 0 + # average_bill_dict[i + 1] = float(sum(bill_dict[i + 1][0][year] for year in bill_dict[i + 1][0])) / len(bill_dict[i + 1][0]) for year in proforma_year: for i in range(4): @@ -92,6 +100,8 @@ def organize_bill_overview(bill_overview, analysis_date): pass else: bill_dict[i + 1][0][year] = average_bill_dict[i + 1] + if bill_dict[i + 1][0][year] == 0: + bill_dict[i + 1][0][year] = average_bill_dict[i + 1] bill_overview_organized = { 'electricity': bill_dict[1][0], 'gas': bill_dict[2][0], diff --git a/bpfin/tests/test_financials/test_income_statement_form_hist.py b/bpfin/tests/test_financials/test_income_statement_form_hist.py index 9114f18..5680325 100644 --- a/bpfin/tests/test_financials/test_income_statement_form_hist.py +++ b/bpfin/tests/test_financials/test_income_statement_form_hist.py @@ -19,10 +19,8 @@ def test_income_statement_character(): def test_form_income_statement_hist(): input_raw_income_input = db.raw_income_input input_bill_overview_organized = db.bill_overview_organized - input_analysis_date = db.analysis_date output_dict = db.income_statement_full result_dict = form_income_statement_hist( input_raw_income_input, - input_bill_overview_organized, - input_analysis_date) + input_bill_overview_organized) assert output_dict == result_dict diff --git a/bpfin/tests/testdata/sample_data.py b/bpfin/tests/testdata/sample_data.py index b7a8053..a9650cb 100644 --- a/bpfin/tests/testdata/sample_data.py +++ b/bpfin/tests/testdata/sample_data.py @@ -90,7 +90,7 @@ annual_bill_electricity = { 2028: 43325.235463581725, 2029: 44211.298795796341, 2030: 45097.667796776521, 2031: 45986.665329650692, 2032: 46886.305428683903, 2033: 47806.578908870637, 2034: 48751.551094031129, 2035: 49722.255450564422, 2036: 50718.832984188753} -annual_bill_gas = {2015: 1020, 2016: 1220, 2017: 1520} +annual_bill_gas = {2014: 0, 2015: 1020, 2016: 1220, 2017: 1520} annual_bill_oil = {2015: 1010, 2016: 1210, 2017: 1510} annual_bill_water = {2015: 0, 2016: 0, 2017: 0} -- GitLab