Skip to content

Commit

Permalink
Merge branch 'master' into add-dropq-test
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Jun 5, 2017
2 parents 22950f2 + 2fadfed commit 9c8c2ef
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 46 deletions.
2 changes: 1 addition & 1 deletion file-upload-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ is installed using this command `conda install -c ospc taxcalc`.

The contents of this directory include JSON reform and assumption
files used in the cross-checking. The local-computer results are
generated by the `cli-results` bash script in this directory.
generated by the `cli-results.sh` bash script in this directory.

The TaxBrain results are located at `http://www.ospc.org/taxbrain/RUN/`
where `RUN` is the number of the TaxBrain run.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# USAGE: ./cli-results [save]
# USAGE: ./cli-results.sh [save]

if [ -f "puf.csv" ]; then
echo "STARTING WITH CLI-RESULTS : `date`"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# USAGE: ./install_local_taxcalc_package
# USAGE: ./install_local_taxcalc_package.sh
# ACTION: (1) uninstalls any installed taxcalc package (conda uninstall)
# (2) executes "conda install conda-build" (if necessary)
# (3) builds local taxcalc=0.0.0 package (conda build)
Expand All @@ -12,7 +12,7 @@ echo "STARTING : `date`"
# uninstall any existing taxcalc conda package
conda list taxcalc | awk '$1~/taxcalc/{rc=1}END{exit(rc)}'
if [ $? -eq 1 ]; then
./uninstall_taxcalc_package
./uninstall_taxcalc_package.sh
fi

# install conda-build package if not present
Expand All @@ -39,7 +39,7 @@ rmdir dist/
rm -fr taxcalc.egg-info/*
rmdir taxcalc.egg-info/

echo "Execute './uninstall_taxcalc_package' after testing CLI"
echo "Execute './uninstall_taxcalc_package.sh' after testing CLI"

echo "FINISHED : `date`"
exit 0
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# USAGE: ./uninstall_local_taxcalc_package
# USAGE: ./uninstall_local_taxcalc_package.sh
# NOTE: for those with experience working with compiled languages,
# uninstalling a conda package is analogous to 'make clean'
conda uninstall taxcalc --yes 2>&1 > /dev/null
7 changes: 3 additions & 4 deletions taxcalc/dropq/dropq.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
import numpy as np
import pandas as pd
from taxcalc.dropq.dropq_utils import (dropq_calculate,
results,
random_seed,
dropq_summary)
from taxcalc import TABLE_LABELS, proportional_change_gdp
from taxcalc import results, TABLE_LABELS, proportional_change_gdp


# specify constants
Expand Down Expand Up @@ -54,8 +53,8 @@ def run_nth_year_tax_calc_model(year_n, start_year,
mask_computed=True)

# extract raw results from calc1 and calc2
rawres1 = results(calc1)
rawres2 = results(calc2)
rawres1 = results(calc1.records)
rawres2 = results(calc2.records)

# seed random number generator with a seed value based on user_mods
seed = random_seed(user_mods)
Expand Down
16 changes: 3 additions & 13 deletions taxcalc/dropq/dropq_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from taxcalc.utils import (add_income_bins, add_weighted_income_bins,
means_and_comparisons, get_sums,
weighted, weighted_avg_allcols,
create_distribution_table,
create_distribution_table, results,
STATS_COLUMNS, TABLE_COLUMNS, WEBAPP_INCOME_BINS)


Expand All @@ -38,16 +38,6 @@ def check_user_mods(user_mods):
raise ValueError('user_mods has extra keys: {}'.format(extra_keys))


def results(calc):
"""
Return DataFrame containing results for STATS_COLUMNS Records variables.
"""
outputs = []
for col in STATS_COLUMNS:
outputs.append(getattr(calc.records, col))
return pd.DataFrame(data=np.column_stack(outputs), columns=STATS_COLUMNS)


def dropq_calculate(year_n, start_year,
taxrec_df, user_mods,
behavior_allowed, mask_computed):
Expand Down Expand Up @@ -112,8 +102,8 @@ def dropq_calculate(year_n, start_year,
calc1p.calc_all()
assert calc1p.current_year == start_year
# compute mask that shows which of the calc1 and calc1p results differ
res1 = results(calc1)
res1p = results(calc1p)
res1 = results(calc1.records)
res1p = results(calc1p.records)
mask = (res1.iitax != res1p.iitax)
else:
mask = None
Expand Down
4 changes: 0 additions & 4 deletions taxcalc/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ def EI_PayrollTax(SS_Earnings_c, e00200, e00200p, e00200s,
# compute OASDI part of payroll taxes
ptax_oasdi = ptax_ss_was_p + ptax_ss_was_s + setax_ss_p + setax_ss_s

# compute self-employment tax on taxable self-employment income
setax_ss_p = FICA_ss_trt * txearn_sey_p
setax_ss_s = FICA_ss_trt * txearn_sey_s

# compute earned* variables and AGI deduction for
# "employer share" of self-employment tax, c03260
# Note: c03260 is the amount on 2015 Form 1040, line 27
Expand Down
9 changes: 5 additions & 4 deletions taxcalc/tests/test_dropq.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import pytest
from taxcalc.dropq.dropq_utils import *
from taxcalc.dropq import *
from taxcalc import Policy, Records, Calculator, multiyear_diagnostic_table
from taxcalc import (Policy, Records, Calculator,
multiyear_diagnostic_table, results)


USER_MODS = {
Expand Down Expand Up @@ -168,7 +169,7 @@ def test_dropq_dist_table(groupby, result_type, puf_1991_path):
calc = Calculator(policy=Policy(),
records=Records(data=pd.read_csv(puf_1991_path)))
calc.calc_all()
res = results(calc)
res = results(calc.records)
mask = np.ones(len(res.index))
(res, _) = drop_records(res, res, mask)
if groupby == 'other_income_bins' or result_type == 'other_avg':
Expand All @@ -195,8 +196,8 @@ def test_dropq_diff_table(groupby, res_column, puf_1991_path):
calc2 = Calculator(policy=pol2, records=recs2)
calc1.calc_all()
calc2.calc_all()
res1 = results(calc1)
res2 = results(calc2)
res1 = results(calc1.records)
res2 = results(calc2.records)
assert len(res1.index) == len(res2.index)
mask = np.ones(len(res1.index))
(res1, res2) = drop_records(res1, res2, mask)
Expand Down
2 changes: 1 addition & 1 deletion taxcalc/validation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The current version of the validation tools in this directory should
work on Linux or Mac OS X without any changes and without adding any
extra software. Those who want to use these validation tools on Windows
will have to do three things: (a) install an AWK interpreter,
(b) install a Tcl interpreter, and (c) translate each `tests` bash script
(b) install a Tcl interpreter, and (c) translate each `tests.sh` bash script
into a Windows batch file (tests.bat). The Free Software Foundation
provides a free AWK interpreter for Windows (gawk.exe) and ActiveState
provides a free Tcl interpreter for Windows (tclsh.exe).
Expand Down
2 changes: 1 addition & 1 deletion taxcalc/validation/taxsim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ it to the Internet-TAXSIM website using the `56 1` option (in order to
do the EITC property-income eligibility test exactly without any
smoothing of property income) and requesting detailed intermediate
calculations. These two OUTPUT files are compared using the
`taxdiffs.tcl` script. See the `tests` and `test` scripts in this
`taxdiffs.tcl` script. See the `tests.sh` and `test.sh` scripts in this
directory for more details.

Validation Results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Check command-line arguments
if [[ "$#" -lt 2 || "$#" -gt 3 ]]; then
echo "ERROR: number of command-line arguments not in 2-to-3 range"
echo "USAGE: bash test LYY REFORM [save]"
echo "USAGE: bash test.sh LYY REFORM [save]"
echo " WHERE L is a letter that is valid taxsim_in.tcl L input and"
echo " YY is valid taxsim_in.tcl CALENDAR YEAR (20YY) input.;"
echo " WHERE REFORM is Internet-TAXSIM option (e.g., '50_1') or"
Expand All @@ -24,7 +24,7 @@ if [[ "$#" -eq 3 ]]; then
SAVE=true
else
echo "ERROR: optional third command-line argument must be 'save'"
echo "USAGE: bash test LYY REFORM [save]"
echo "USAGE: bash test.sh LYY REFORM [save]"
touch testerror
exit 1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rm -f testerror
# .... check number of command-line arguments
if [[ "$#" -gt 1 ]]; then
echo "ERROR: can specify at most one command-line argument"
echo "USAGE: ./tests [all]"
echo "USAGE: ./tests.sh [all]"
echo " (using the 'all' option may execute many tests at a time)"
exit 1
fi
Expand All @@ -16,18 +16,18 @@ if [[ "$#" -eq 1 ]]; then
ALLTESTS=true
else
echo "ERROR: optional command-line argument must be all"
echo "USAGE: ./tests [all]"
echo "USAGE: ./tests.sh [all]"
exit 1
fi
fi
# .... execute validation tests
rm -f testerror
if [[ "$ALLTESTS" == true ]] ; then
bash test a15 . &
bash test d15 . &
bash test.sh a15 . &
bash test.sh d15 . &
wait
else
bash test d15 .
bash test.sh d15 .
fi
if [[ -f "testerror" ]]; then
ERROR=1
Expand Down
12 changes: 6 additions & 6 deletions taxcalc/validation/tests → taxcalc/validation/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# .... check number of command-line arguments
if [[ "$#" -gt 1 ]]; then
echo "ERROR: can specify at most one command-line argument"
echo "USAGE: ./tests [all]"
echo "USAGE: ./tests.sh [all]"
echo " (using the 'all' option may execute four tests at a time)"
exit 1
fi
Expand All @@ -14,26 +14,26 @@ if [[ "$#" -eq 1 ]]; then
ALLTESTS=true
else
echo "ERROR: optional command-line argument must be all"
echo "USAGE: ./tests [all]"
echo "USAGE: ./tests.sh [all]"
exit 1
fi
fi
echo "STARTING WITH VALIDATION TESTS : `date`"
if [[ $ALLTESTS == true ]] ; then
# execute all tests sequentially
cd taxsim
bash tests all
bash tests.sh all
cd ..
# cd drake
# bash tests all
# bash tests.sh all
# cd ..
else
# execute basic tests simultaneously
cd taxsim
bash tests &
bash tests.sh &
cd ..
# cd drake
# bash tests &
# bash tests.sh &
# cd ..
wait
fi
Expand Down

0 comments on commit 9c8c2ef

Please sign in to comment.