Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Used np.divide with out and where parameters #5501

Merged
merged 4 commits into from
Jan 23, 2025
Merged
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
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:
- Invalid value when dividing employment_income by total_earnings in marginal tax rate calculation.
9 changes: 7 additions & 2 deletions policyengine_us/variables/household/marginal_tax_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ def formula(person, period, parameters):
employment_income = person("employment_income", period)
self_employment_income = person("self_employment_income", period)
total_earnings = employment_income + self_employment_income
emp_self_emp_ratio = where(
total_earnings > 0, employment_income / total_earnings, 1

emp_self_emp_ratio = np.divide(
employment_income,
total_earnings,
out=np.ones_like(total_earnings, dtype=np.float32),
where=total_earnings > 0,
)

for adult_index in range(1, 1 + adult_count):
alt_sim = sim.get_branch(f"mtr_for_adult_{adult_index}")
for variable in sim.tax_benefit_system.variables:
Expand Down
Loading