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

Revise GrowFactors constructor to handle custom growfactors files #2757

Merged
merged 40 commits into from
Jun 5, 2024

Conversation

martinholmer
Copy link
Collaborator

@martinholmer martinholmer commented Jun 5, 2024

Default is still to use baseline growfactors in the package's growfactors.csv file.
Now users of the Python API can specify custom growth factors to be used by the Records object.

For an example of how to use this new Tax-Calculator feature, we this comment.

duncanhobbs and others added 30 commits September 30, 2021 14:22
Update CDCC rates in reform to be on new scale
Update v4 development branch with latest from master
Sync `v4_development` branch to `master`
@martinholmer martinholmer changed the title Revise GrowFactor constructor to handle custom growfactors files Revise GrowFactors constructor to handle custom growfactors files Jun 5, 2024
Copy link

codecov bot commented Jun 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.42%. Comparing base (e0234b6) to head (afb7df1).
Report is 16 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2757   +/-   ##
=======================================
  Coverage   99.42%   99.42%           
=======================================
  Files          13       13           
  Lines        2605     2607    +2     
=======================================
+ Hits         2590     2592    +2     
  Misses         15       15           
Flag Coverage Δ
unittests 99.42% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
taxcalc/__init__.py 100.00% <100.00%> (ø)
taxcalc/calculator.py 100.00% <ø> (ø)
taxcalc/growfactors.py 100.00% <100.00%> (ø)
taxcalc/parameters.py 100.00% <ø> (ø)

@martinholmer martinholmer merged commit d9b56c7 into PSLmodels:master Jun 5, 2024
9 checks passed
@martinholmer martinholmer deleted the growfactors-ctor branch June 5, 2024 21:07
@donboyd5
Copy link
Contributor

donboyd5 commented Jun 6, 2024

Thanks for this, @martinholmer, it is really helpful.

@martinholmer
Copy link
Collaborator Author

The following Python script illustrates the use of the new feature added in PR #2757:

"""
This gf.py script illustrates use of GrowFactors constructor with custom
growfactors representing a 2020 spike in wage inflation, a feature that
is in Tax-Calculator pull request #2757 and will be included beginning
in the Tax-Calculator 4.0.0 release.

(taxcalc-dev) Tax-Calculator% diff mygf.csv taxcalc/growfactors.csv
11c11
< 2020,1.067957,1.167938,0.947032,1.00799,1.041121,1.116381,1.016054,...
---                                                  ^^
> 2020,1.067957,1.167938,0.947032,1.00799,1.041121,1.006381,1.016054,...

(taxcalc-dev) Tax-Calculator% python gf.py
2112.718 2367.885
"""

from taxcalc import GrowFactors, Policy, Records, Calculator


TAXYEAR = 2022

gf0 = GrowFactors()
gf1 = GrowFactors(growfactors_filename='../Tax-Calculator/mygf.csv')

recs0 = Records('puf.csv', start_year=Records.PUFCSV_YEAR, gfactors=gf0)
recs1 = Records('puf.csv', start_year=Records.PUFCSV_YEAR, gfactors=gf1)

calc0 = Calculator(policy=Policy(), records=recs0)
calc1 = Calculator(policy=Policy(), records=recs1)

calc0.advance_to_year(TAXYEAR)
calc1.advance_to_year(TAXYEAR)

calc0.calc_all()
calc1.calc_all()

itax0 = calc0.weighted_total('iitax')
itax1 = calc1.weighted_total('iitax')

assert itax1 > itax0
print(round(itax0*1e-9, 3), round(itax1*1e-9, 3))

Executing the above script produces these results:

(taxcalc-dev) Tax-Calculator% python gf.py
2112.718 2367.885

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.

5 participants