Skip to content

Commit

Permalink
Merge pull request #123 from PolicyEngine/yaml-bug-fix
Browse files Browse the repository at this point in the history
Fix YAML tests don't fill `Simulation.input_variables` #122
  • Loading branch information
nikhilwoodruff authored Oct 5, 2023
2 parents bf2430d + 04945f4 commit 5c5e636
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 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: patch
changes:
fixed:
- Bug causing YAML tests to not populate `Simulation.input_variables`.
13 changes: 11 additions & 2 deletions policyengine_core/simulations/simulation_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,23 @@ def build_from_dict(
key in tax_benefit_system.entities_plural()
for key in input_dict.keys()
):
return self.build_from_entities(
simulation = self.build_from_entities(
tax_benefit_system, input_dict, simulation
)
else:
return self.build_from_variables(
simulation = self.build_from_variables(
tax_benefit_system, input_dict, simulation
)

simulation.input_variables = [
variable.name
for variable in simulation.tax_benefit_system.variables.values()
if len(simulation.get_holder(variable.name).get_known_periods())
> 0
]

return simulation

def build_from_entities(
self,
tax_benefit_system: "TaxBenefitSystem",
Expand Down

0 comments on commit 5c5e636

Please sign in to comment.