ospc-org / ospc.org

Source code for PolicyBrain, ospc.org, and related assets.
MIT License
24 stars 32 forks source link

Copying TaxBrain reform to Tax-Calculator API #957

Open MaxGhenis opened 5 years ago

MaxGhenis commented 5 years ago

Is there an easy way to copy reforms between TaxBrain and the Tax-Calculator API (Python or CLI)? I made a reform in TaxBrain (https://apps.ospc.org/taxbrain/38482) and tried to copy the reform from the top, but since it splits out each element of the MARS array into their own parameters (e.g., _CG_brk3_single), I had to re-create it.

hdoupe commented 5 years ago

Hey Max, you can convert the reform like this:

In [1]: from taxcalc import Calculator

In [2]:             ]
   ...:         },
   ...:         "_AMT_CG_brk3_separate": {
   ...:             "2017": [
   ...:                 10000000.0
   ...:             ]
   ...:         },
   ...:         "_AMT_CG_brk3_headhousehold": {
   ...:             "2017": [
   ...:                 10000000.0
   ...:             ]
   ...:         },
   ...:         "_AMT_CG_rt4": {
   ...:             "2017": [
   ...:                 0.7
   ...:             ]
   ...:         },
   ...:         "_II_brk7_single": {
   ...:             "2017": [
   ...:                 10000000.0
   ...:             ]
   ...:         },
   ...:         "_II_brk7_joint": {
   ...:             "2017": [
   ...:                 10000000.0
   ...:             ]
   ...:         },
   ...:         "_II_brk7_separate": {
   ...:             "2017": [
   ...:                 10000000.0
   ...:             ]
   ...:         },
   ...:         "_II_brk7_headhousehold": {
   ...:             "2017": [
   ...:                 10000000.0
   ...:             ]
   ...:         },
   ...:         "_II_rt8": {
   ...:             "2017": [
   ...:                 0.7
   ...:             ]
   ...:         },
   ...:         "_PT_brk7_single": {
   ...:             "2017": [
   ...:                 10000000.0
   ...:             ]
   ...:         },
   ...:         "_PT_brk7_joint": {
   ...:             "2017": [
   ...:                 10000000.0
   ...:             ]
   ...:         },
   ...:         "_PT_brk7_separate": {
   ...:             "2017": [
   ...:                 10000000.0
   ...:             ]
   ...:         },
   ...:         "_PT_brk7_headhousehold": {
   ...:             "2017": [
   ...:                 10000000.0
   ...:             ]
   ...:         },
   ...:         "_PT_rt8": {
   ...:             "2017": [
   ...:                 0.7
   ...:             ]
   ...:         }
   ...:     }
   ...: }"""

In [3]: spec = Calculator.read_json_param_objects(reform=ref, assump=None)

In [4]: spec
Out[4]: 
{'policy': {2017: {'_CG_rt4': [0.7],
   '_AMT_CG_rt4': [0.7],
   '_II_rt8': [0.7],
   '_PT_rt8': [0.7],
   '_CG_brk3': [[10000000.0, 10000000.0, 10000000.0, 10000000.0, 9e+99]],
   '_AMT_CG_brk3': [[10000000.0, 10000000.0, 10000000.0, 10000000.0, 9e+99]],
   '_II_brk7': [[10000000.0, 10000000.0, 10000000.0, 10000000.0, 9e+99]],
   '_PT_brk7': [[10000000.0, 10000000.0, 10000000.0, 10000000.0, 9e+99]]}},
 'consumption': {},
 'behavior': {},
 'growdiff_baseline': {},
 'growdiff_response': {},
 'growmodel': {}}

In [5]: