Skip to content

Commit

Permalink
Used np.divide with out and where parameters (#5501)
Browse files Browse the repository at this point in the history
* Used np.divide with out and where parameters

* Change log

* Populate changelog_entry yaml file

* Made changes in changelog_entry yaml file
  • Loading branch information
SonaliBedge authored Jan 23, 2025
1 parent b50fa56 commit 89624f0
Show file tree
Hide file tree
Showing 2 changed files with 11 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:
- 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

0 comments on commit 89624f0

Please sign in to comment.