Skip to content

Commit

Permalink
Add new single year imapcts and Winners and Loosers
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelMakarchuk committed Jan 20, 2025
1 parent a6c3ec0 commit d9c3a4a
Show file tree
Hide file tree
Showing 33 changed files with 1,236 additions and 1,570 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file modified __pycache__/baseline_impacts.cpython-310.pyc
Binary file not shown.
Binary file modified __pycache__/constants.cpython-310.pyc
Binary file not shown.
Binary file added __pycache__/introduction.cpython-310.pyc
Binary file not shown.
Binary file modified __pycache__/policy_config.cpython-310.pyc
Binary file not shown.
16 changes: 15 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"Design and compare changes to the state and local tax (SALT) deduction and alternative minimum tax (AMT)"
)


# Initialize nationwide impacts if not already done
if "nationwide_impacts" not in st.session_state:
try:
Expand Down Expand Up @@ -94,6 +95,18 @@ def get_reform_name(policy_config, baseline):
salt_full = "salt_uncapped"
elif policy_config["salt_repealed"]:
salt_full = "salt_0_cap"
elif policy_config["salt_cap"] == "$15k":
# Handle the 15k case with potential marriage bonus
if policy_config.get("salt_marriage_bonus"):
if policy_config.get("salt_phaseout") != "None":
salt_full = "salt_15_30_k_with_phaseout"
else:
salt_full = "salt_15_30_k_without_phaseout"
else:
if policy_config.get("salt_phaseout") != "None":
salt_full = "salt_15_k_with_phaseout"
else:
salt_full = "salt_15_k_without_phaseout"
else: # Current Policy selected
salt_base = "salt_tcja_base"
marriage_bonus = policy_config.get("salt_marriage_bonus", False)
Expand All @@ -108,6 +121,7 @@ def get_reform_name(policy_config, baseline):
else:
salt_full = salt_base

# Rest of the function remains the same
# Handle AMT suffix based on configuration
if policy_config.get("amt_repealed"):
amt_suffix = "_amt_repealed"
Expand All @@ -131,6 +145,7 @@ def get_reform_name(policy_config, baseline):
if policy_config.get("behavioral_responses")
else "_behavioral_responses_no"
)

other_tcja_provisions_suffix = (
"_other_tcja_provisions_extended_no"
if policy_config.get("other_tcja_provisions_extended") == "Current Law"
Expand All @@ -140,7 +155,6 @@ def get_reform_name(policy_config, baseline):
# Add baseline suffix
baseline_suffix = f"_vs_{baseline.lower().replace(' ', '_')}"

# Add other TCJA provisions suffix
return f"{salt_full}{amt_suffix}{behavioral_suffix}{other_tcja_provisions_suffix}{baseline_suffix}"

reform_name = get_reform_name(
Expand Down
16 changes: 8 additions & 8 deletions baseline_impacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ def get_baseline_data(self, baseline_type="current_law"):

if baseline_type == "current_law":
# For current law, use values from baseline_deficit.csv
baseline_deficit["revenue_impact"] = baseline_deficit["deficit_total"]
baseline_deficit["total_income_change"] = baseline_deficit["deficit_total"]
return baseline_deficit
else: # current policy
# Calculate TCJA impact as difference between tcja_extension_baseline and baseline
tcja_data = self.budget_window_data[
self.budget_window_data["reform"] == "tcja_extension_baseline"
]["revenue_impact"]
]["total_income_change"]
baseline_data = self.budget_window_data[
self.budget_window_data["reform"] == "baseline"
]["revenue_impact"]
]["total_income_change"]
tcja_impact = tcja_data.values - baseline_data.values

# Add TCJA impact to baseline deficit
baseline_deficit["revenue_impact"] = (
baseline_deficit["total_income_change"] = (
baseline_deficit["deficit_total"] + tcja_impact
)
return baseline_deficit
Expand Down Expand Up @@ -66,7 +66,7 @@ def create_metric_chart(self, current_law_data, current_policy_data, metric):
)

# Get display title based on metric
if metric == "revenue_impact":
if metric == "total_income_change":
title = "Total Deficit"
y_axis_title = "Total Deficit"
else:
Expand Down Expand Up @@ -121,16 +121,16 @@ def display_baseline_impacts():
if not current_law_data.empty and not current_policy_data.empty:
# Only show metrics that exist in the data
available_metrics = [
col for col in current_law_data.columns if col in ["revenue_impact"]
col for col in current_law_data.columns if col in ["total_income_change"]
]

def format_metric_name(x):
if x == "revenue_impact":
if x == "total_income_change":
return "Total Deficit"
return x.replace("_", " ").title()

if len(available_metrics) > 0:
selected_metric = "revenue_impact"
selected_metric = "total_income_change"
# selected_metric = st.selectbox(
# "Select Metric",
# available_metrics,
Expand Down
Binary file added nationwide_impacts/.DS_Store
Binary file not shown.
Binary file modified nationwide_impacts/__pycache__/charts.cpython-310.pyc
Binary file not shown.
Binary file modified nationwide_impacts/__pycache__/impacts.cpython-310.pyc
Binary file not shown.
Binary file modified nationwide_impacts/__pycache__/tables.cpython-310.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions nationwide_impacts/charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ def plot_time_series(impact_data):
)
return fig

# Ensure revenue_impact is numeric and convert to billions
# Ensure total_income_change is numeric and convert to billions
try:
y_values = pd.to_numeric(impact_data["revenue_impact"]) / 1e9
y_values = pd.to_numeric(impact_data["total_income_change"]) / 1e9
except (KeyError, ValueError):
# Handle case where revenue_impact column doesn't exist or contains invalid data
# Handle case where total_income_change column doesn't exist or contains invalid data
fig = go.Figure()
fig.add_annotation(
text="Invalid revenue impact data",
Expand Down
Loading

0 comments on commit d9c3a4a

Please sign in to comment.