PolicyEngine / policyengine-us

The PolicyEngine US Python package contains a rules engine of the US tax-benefit system, and microdata generation for microsimulation analysis.
https://policyengine.org/us
GNU Affero General Public License v3.0
103 stars 175 forks source link

Divide-by-zero problem in new Pell Grant calculations #2871

Closed martinholmer closed 1 year ago

martinholmer commented 1 year ago

This is the new warning message:

policyengine_us/tests/test_variables.py::test_variable[marginal_tax_rate]
policyengine_us/tests/test_variables.py::test_variable[marginal_tax_rate]
policyengine_us/tests/test_variables.py::test_variable[cliff_gap]
policyengine_us/tests/microsimulation/test_microsim.py::test_microsim_runs_cps
  /Users/mrh/work/policyengine-us/policyengine_us/variables/
     gov/ed/pell_grant/efc/head/pell_grant_head_contribution.py:29: 
  RuntimeWarning: invalid value encountered in true_divide
           return total / dependents

It seems as if the dependents variable is often zero in the CPS data.

MaxGhenis commented 1 year ago

@CalebPena could you apply a mask to this calculation to avoid this warning? You can search the repo for examples.

MaxGhenis commented 1 year ago

I went ahead with this as it caused an API issue