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

Fix invalid value error in weekly_hours_worked file by using np.divide #5505

Merged
merged 10 commits into from
Jan 27, 2025

Conversation

SonaliBedge
Copy link
Contributor

@SonaliBedge SonaliBedge commented Jan 23, 2025

Fixes issue #4889 and #4890 (Used np.divide NumPy function with out and where parameters to solve invalid value encountered when dividing income_effect by original_earnings and dividing substitution_effect by original_earnings in weekly hours worked calculation in weekly hours worked file.)

lsr_relative_change = np.divide(
income_effect,
original_earnings,
out=np.zeros_like(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid awkward line breaks.

Suggested change
out=np.zeros_like(
# Assign no LSR change to people with no original earnings to avoid dividing by zero.
out=np.zeros_like(income_effect, dtype=np.float32),
where=original_earnings != 0,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try make format and please add the comment I suggested

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.10%. Comparing base (cb92a56) to head (a93aed0).
Report is 401 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5505      +/-   ##
==========================================
- Coverage   99.12%   99.10%   -0.03%     
==========================================
  Files        2592     2679      +87     
  Lines       37707    38827    +1120     
  Branches      162      168       +6     
==========================================
+ Hits        37378    38478    +1100     
- Misses        297      315      +18     
- Partials       32       34       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@MaxGhenis MaxGhenis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a unit test for this?

@MaxGhenis MaxGhenis changed the title Fix invalid value error in weekly_hours_workd file by using np.divide… Fix invalid value error in weekly_hours_worked file by using np.divide Jan 27, 2025
@SonaliBedge SonaliBedge requested a review from MaxGhenis January 27, 2025 21:30
@MaxGhenis MaxGhenis merged commit 3703022 into PolicyEngine:master Jan 27, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants