Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions changelog.d/fix-microsim-self-employment.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the microsimulation smoke test for self-employment income when weighted business losses exceed profits.
13 changes: 10 additions & 3 deletions policyengine_us/tests/microsimulation/test_microsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@ def test_microsim_runs(dataset: str, year: int):
f"{decile_var} out of bounds."
)

# Check that the microsim calculates important variables as nonzero in current year.
for var in ["employment_income", "self_employment_income"]:
assert sim.calc(var, period=2024).sum() > 0, f"{var} is zero in 2024."
# Employment income should aggregate positive in the sample.
assert sim.calc("employment_income", period=2024).sum() > 0, (
"employment_income is zero in 2024."
)

# Self-employment is net business income, so weighted totals can be
# negative when losses outweigh profits in the sampled records.
assert sim.calc("self_employment_income", period=2024).abs().sum() > 0, (
"self_employment_income is zero in 2024."
)


def test_county_persists_across_periods():
Expand Down
Loading