Skip to content

Commit

Permalink
Fix bug in reform handling (#128)
Browse files Browse the repository at this point in the history
* Apply reforms before utilities

* Fix reform bug
  • Loading branch information
nikhilwoodruff authored Nov 22, 2023
1 parent 444b585 commit 3153b50
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
fixed:
- Reforms always apply before parameter utilities.
14 changes: 11 additions & 3 deletions policyengine_core/simulations/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,29 @@ def __init__(
dataset: Union[str, Type[Dataset]] = None,
reform: Reform = None,
):
reform_applied_after = False
if tax_benefit_system is None:
if (
self.default_tax_benefit_system_instance is not None
and reform is None
):
tax_benefit_system = self.default_tax_benefit_system_instance
else:
tax_benefit_system = self.default_tax_benefit_system(
reform=reform
)
# If reform is taken as an arg, pass it
try:
tax_benefit_system = self.default_tax_benefit_system(
reform=reform
)
except:
tax_benefit_system = self.default_tax_benefit_system()
reform_applied_after = True
self.tax_benefit_system = tax_benefit_system

self.reform = reform
self.tax_benefit_system = tax_benefit_system

if reform_applied_after and reform is not None:
self.apply_reform(reform)
self.branch_name = "default"

if dataset is None:
Expand Down

0 comments on commit 3153b50

Please sign in to comment.