Skip to content

Commit

Permalink
Merge pull request #43 from Peter-Metz/fix
Browse files Browse the repository at this point in the history
Add Python 3.8 to Travis and remove extraneous line in multi_cruncher.py
  • Loading branch information
Peter-Metz authored Sep 14, 2020
2 parents 1fb1fde + bcbf242 commit 1823177
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ language: python
python:
- "3.6"
- "3.7"
- "3.8"

before_install:
- "pip install -U pip"
Expand Down
2 changes: 1 addition & 1 deletion taxcrunch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from taxcrunch.multi_cruncher import *

name = "taxcrunch"
__version__ = "0.4.2"
__version__ = "0.4.3"
5 changes: 4 additions & 1 deletion taxcrunch/multi_cruncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class instance: Batch
def __init__(self, path):
self.path = path
self.invar, self.invar_marg, self.rows = self.read_input()
self.mtr = self.calc_mtr(reform_file=None)

self.TC_VARS = [
"RECID",
Expand Down Expand Up @@ -180,6 +179,7 @@ def create_table(
adjust_ratios=None,
)

# if tc_vars and tc_labels are not specified, defaults are used
if tc_vars is None:
tc_vars = self.TC_VARS
if tc_labels is None:
Expand All @@ -188,13 +188,15 @@ def create_table(
assert len(tc_vars) > 0
assert len(tc_vars) == len(tc_labels)

# if no reform file is passed, table will show current law values
if reform_file is None:
pol = tc.Policy()
assert be_sub == be_inc == be_cg == 0
calc = tc.Calculator(policy=pol, records=recs)
calc.advance_to_year(year)
calc.calc_all()
calcs = calc.dataframe(tc_vars)
# if a reform file is passed, table will show reform values
else:
pol = self.get_pol(reform_file)
calc = tc.Calculator(policy=pol, records=recs)
Expand All @@ -204,6 +206,7 @@ def create_table(
_, df2br = br.response(calc_base, calc, response_elasticities, dump=True)
calcs = df2br[tc_vars]

# if include_mtr is True, the tables includes three columns with MTRs
if include_mtr:
mtr = self.calc_mtr(reform_file)
mtr_df = pd.DataFrame(data=mtr).transpose()
Expand Down
10 changes: 10 additions & 0 deletions taxcrunch/tests/test_multi_cruncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ def test_custom_output_cols(crunch=b):
b.create_table(tc_vars=["fake_var1", "fake_var2"], tc_labels=custom_labels)


def test_mtr_cols(crunch=b):

mtr_cols = ["Payroll Tax MTR", "Income Tax MTR", "Combined MTR"]
table = b.create_table()
assert set(mtr_cols).issubset(table.columns)

table_no_mtr = b.create_table(include_mtr=False)
assert set(mtr_cols).issubset(table_no_mtr.columns) is False


def test_qbid_params():
"""
Adpots a test from Tax-Calculator that checks QBID calculations against
Expand Down

0 comments on commit 1823177

Please sign in to comment.