Skip to content

Commit 7bd143b

Browse files
Merge pull request #79 from PolicyEngine/nikhilwoodruff/issue78
Add general `Simulation.calculate` method
2 parents 5996e46 + 8463268 commit 7bd143b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

changelog_entry.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- bump: minor
2+
changes:
3+
added:
4+
- General `calculate` method.

policyengine/simulation.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,26 @@ def _data_handle_cps_special_case(self):
307307
)
308308
self.data = Dataset.from_file(self.data, "2023")
309309

310+
def calculate(
311+
self,
312+
) -> (
313+
SingleEconomy
314+
| EconomyComparison
315+
| SingleHousehold
316+
| HouseholdComparison
317+
):
318+
"""Calculate the default output statistics for the simulation type."""
319+
if self.options.scope == "macro":
320+
if self.is_comparison:
321+
return self.calculate_economy_comparison()
322+
else:
323+
return self.calculate_single_economy()
324+
elif self.options.scope == "household":
325+
if self.is_comparison:
326+
return self.calculate_household_comparison()
327+
else:
328+
return self.calculate_single_household()
329+
310330
def calculate_economy_comparison(self) -> EconomyComparison:
311331
"""Calculate comparison statistics between two economic scenarios."""
312332
return calculate_economy_comparison(self)

0 commit comments

Comments
 (0)