Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ def calculate_economy_comparison(
reform: SingleEconomy = simulation.calculate_single_economy(reform=True)
options = simulation.options
country_id = options.country
if baseline.type == "general":
if not simulation.options.include_cliffs:
budgetary_impact_data = budgetary_impact(baseline, reform)
detailed_budgetary_impact_data = detailed_budgetary_impact(
baseline, reform, country_id
Expand Down Expand Up @@ -839,7 +839,7 @@ def calculate_economy_comparison(
labor_supply_response=labor_supply_response_data,
constituency_impact=constituency_impact_data,
)
elif baseline.type == "cliff":
else:
return dict(
baseline=dict(
cliff_gap=baseline.cliff_gap,
Expand Down
14 changes: 13 additions & 1 deletion policyengine/outputs/macro/single/calculate_single_economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class SingleEconomy(BaseModel):
weekly_hours_substitution_effect: float | None
type: str
programs: Dict[str, float] | None
cliff_gap: float | None = None
cliff_share: float | None = None


@dataclass
Expand Down Expand Up @@ -331,6 +333,7 @@ def calculate_uk_programs(self) -> Dict[str, float]:
def calculate_single_economy(
simulation: Simulation, reform: bool = False
) -> Dict:
include_cliffs = simulation.options.include_cliffs
task_manager = GeneralEconomyTask(
(
simulation.baseline_simulation
Expand Down Expand Up @@ -382,6 +385,13 @@ def calculate_single_economy(
except:
total_state_tax = 0

if include_cliffs:
cliff_gap = task_manager.simulation.calculate("cliff_gap")
is_on_cliff = task_manager.simulation.calculate("is_on_cliff")
total_cliff_gap = cliff_gap.sum()
total_adults = task_manager.simulation.calculate("is_adult").sum()
cliff_share = is_on_cliff.sum() / total_adults

return SingleEconomy(
**{
"total_net_income": total_net_income,
Expand Down Expand Up @@ -414,7 +424,9 @@ def calculate_single_economy(
"age": age,
**labor_supply_responses,
**lsr_working_hours,
"type": "general",
"type": "general" if include_cliffs else "cliff",
"programs": uk_programs,
"cliff_gap": float(total_cliff_gap) if include_cliffs else None,
"cliff_share": float(cliff_share) if include_cliffs else None,
}
)
4 changes: 4 additions & 0 deletions policyengine/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class SimulationOptions(BaseModel):
"[Analysis title]",
description="The title of the analysis (for charts). If not provided, a default title will be generated.",
)
include_cliffs: bool | None = Field(
False,
description="Whether to include tax-benefit cliffs in the simulation analyses. If True, cliffs will be included.",
)


class Simulation:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "policyengine"
version = "0.3.1"
version = "0.3.2"
description = "A package to conduct policy analysis using PolicyEngine tax-benefit models."
readme = "README.md"
authors = [
Expand Down
Loading