Skip to content

Commit

Permalink
Merge branch 'master' into 0-23-0
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Nov 13, 2018
2 parents cafc5c0 + 67ca17e commit 4d89d86
Show file tree
Hide file tree
Showing 32 changed files with 292 additions and 1,565 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[run]
omit =
taxcalc/_version.py
taxcalc/calcfunctions.py
taxcalc/*.json
taxcalc/cli/*
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ TESTS_JSON_FILES := $(shell ls -l ./taxcalc/tests/*json | awk '{print $$9}')
PYLINT_FILES := $(shell grep -rl --include="*py" disable=locally-disabled .)
PYLINT_OPTIONS = --disable=locally-disabled --score=no --jobs=4
RECIPE_FILES := $(shell ls -l ./docs/cookbook/recipe*py | awk '{print $$9}')
RECIPE_OPTIONS = --disable=C0103,C0111,W0401,W0614 --score=no --jobs=4
RECIPE_OPTIONS = --disable=C0103,C0111,W0401,W0614,E0401 --score=no --jobs=4

.PHONY=cstest
cstest:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Python 3.6.5](https://img.shields.io/badge/python-3.6.5-blue.svg)](https://www.python.org/downloads/release/python-365/)
[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)
[![Build Status](https://travis-ci.org/open-source-economics/Tax-Calculator.svg?branch=master)](https://travis-ci.org/open-source-economics/Tax-Calculator)
[![Codecov](https://codecov.io/gh/open-source-economics/Tax-Calculator/branch/master/graph/badge.svg)](https://codecov.io/gh/open-source-economics/Tax-Calculator)

Expand Down
4 changes: 2 additions & 2 deletions conda.recipe/install_local_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ echo "BUILD-PREP..."

# check version of conda package
conda list conda | awk '$1=="conda"{v=$2;gsub(/\./,"",v);nv=v+0;if(nv<444)rc=1}END{exit(rc)}'
if [ $? -eq 1 ]; then
if [[ $? -eq 1 ]]; then
echo "==> Installing conda 4.4.4+"
conda install conda>=4.4.4 --yes 2>&1 > /dev/null
echo "==> Continuing to build new taxcalc package"
fi

# install conda-build package if not present
conda list build | awk '$1~/conda-build/{rc=1}END{exit(rc)}'
if [ $? -eq 0 ]; then
if [[ $? -eq 0 ]]; then
echo "==> Installing conda-build package"
conda install conda-build --yes 2>&1 > /dev/null
echo "==> Continuing to build new taxcalc package"
Expand Down
4 changes: 2 additions & 2 deletions conda.recipe/remove_local_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# removing a local conda package is analogous to a "make clean" operation

# uninstall any existing taxcalc conda package
conda list taxcalc | awk '$1~/taxcalc/{rc=1}END{exit(rc)}'
if [ $? -eq 1 ]; then
conda list taxcalc | awk '$1=="taxcalc"{rc=1}END{exit(rc)}'
if [[ $? -eq 1 ]]; then
conda uninstall taxcalc --yes 2>&1 > /dev/null
fi

Expand Down
15 changes: 8 additions & 7 deletions docs/cookbook.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ <h2 id="techniques">Preliminaries: Recipe Techniques</h2>
and give it a new file name before you start to modify the recipe.</p>

<p>The Calculator object is the central object in Tax-Calculator and
it is created by passing four secondary objects (a Policy object, a
Records object, a Behavior object, and a Consumption object) to the
it is created by passing three secondary objects (a Policy object, a
Records object, and a Consumption object) to the
Calculator class constructor. When modifying a recipe, following a
few rules will minimize the chance of running into problems.</p>

<p>Fully specify Consumption, Behavior, Records, and Policy objects
<p>Fully specify Policy, Records, and Consumption objects
before passing them to the Calculator class constructor.</p>

<p>After initializing a Calculator object, manipulate it using only
Expand Down Expand Up @@ -236,16 +236,17 @@ <h2 id="recipe02">Advanced Recipe: (2) Estimating Behavioral Response

<p>This is an advanced recipe that should be followed only after
mastering the <a href="#recipe00">basic recipe</a>. This recipe
shows how to analyze the behavioral responses to a tax reform.</p>
shows how to analyze the behavioral responses to a tax reform using
the Behavioral-Responses <kbd>behresp</kbd> package. Before following
this recipe, be sure to install the <kbd>behresp</kbd> package on your
compter by executing this at the command prompt:
<kbd>conda install -c OSPC behresp</kbd></p>

<p><b>Ingredients</b></p>

<p><a href="reformA.json.html" target="_blank">Policy reform</a> in
the <kbd>ingredients/reformA.json</kbd> file.</p>

<p><a href="assumpA.json.html" target="_blank">Economic assumptions</a> in
the <kbd>ingredients/assumpA.json</kbd> file.</p>

<p><b>Instructions</b></p>

<p><a href="recipe02.py.html" target="_blank">Step-by-step
Expand Down
16 changes: 0 additions & 16 deletions docs/cookbook/ingredients/assumpA.json

This file was deleted.

40 changes: 19 additions & 21 deletions docs/cookbook/recipe02.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from taxcalc import *
import behresp

# use publicly-available CPS input file
recs = Records.cps_constructor()

# specify Calculator object representing current-law policy
# specify baseline Calculator object representing current-law policy
pol = Policy()
calc1 = Calculator(policy=pol, records=recs)

Expand All @@ -14,37 +15,34 @@
calc1.calc_all()
itax_rev1 = calc1.weighted_total('iitax')

# read JSON reform file and use (the default) static analysis assumptions
# read JSON reform file
reform_filename = './ingredients/reformA.json'
params = Calculator.read_json_param_objects(reform=reform_filename,
assump=None)

# specify Calculator object for static analysis of reform policy
pol.implement_reform(params['policy'])
calc2 = Calculator(policy=pol, records=recs)
calc2sa = Calculator(policy=pol, records=recs)

# calculate reform income tax liabilities for cyr under static assumptions
calc2.advance_to_year(cyr)
calc2.calc_all()
itax_rev2 = calc2.weighted_total('iitax')
calc2sa.advance_to_year(cyr)
calc2sa.calc_all()
itax_rev2sa = calc2sa.weighted_total('iitax')

# read JSON reform file and (dynamic) behavioral-analysis assumptions
assump_filename = './ingredients/assumpA.json'
params = Calculator.read_json_param_objects(reform=reform_filename,
assump=assump_filename)
behv = Behavior()
behv.update_behavior(params['behavior'])
# specify behavioral-response assumptions
behresp_json = '{"BE_sub": {"2018": 0.25}}'
behresp_dict = Calculator.read_json_assumptions(behresp_json)

# specify Calculator object for behavioral-response analysis of reform policy
calc3 = Calculator(policy=pol, records=recs, behavior=behv)
# specify Calculator object for analysis of reform with behavioral response
calc2br = Calculator(policy=pol, records=recs)
calc2br.advance_to_year(cyr)
_, df2br = behresp.response(calc1, calc2br, behresp_dict)

# calculate reform income tax liabilities for cyr under dynamic assumptions
calc3.advance_to_year(cyr)
calc3br = Behavior.response(calc1, calc3)
itax_rev3 = calc3br.weighted_total('iitax')
# calculate reform income tax liabilities for cyr with behavioral response
itax_rev2br = (df2br['iitax'] * df2br['s006']).sum()

# print total revenue estimates for cyr
# print total income tax revenue estimates for cyr
# (estimates in billons of dollars rounded to nearest hundredth of a billion)
print('{}_CURRENT_LAW_P__itax_rev($B)= {:.2f}'.format(cyr, itax_rev1 * 1e-9))
print('{}_REFORM_STATIC__itax_rev($B)= {:.2f}'.format(cyr, itax_rev2 * 1e-9))
print('{}_REFORM_DYNAMIC_itax_rev($B)= {:.2f}'.format(cyr, itax_rev3 * 1e-9))
print('{}_REFORM_STATIC__itax_rev($B)= {:.2f}'.format(cyr, itax_rev2sa * 1e-9))
print('{}_REFORM_DYNAMIC_itax_rev($B)= {:.2f}'.format(cyr, itax_rev2br * 1e-9))
2 changes: 1 addition & 1 deletion docs/cookbook/test_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
RECIPES = glob.glob('./recipe[0-9][0-9].py')

# execute each recipe in RECIPES list and compare output with expected output
for recipe in RECIPES:
for recipe in sorted(RECIPES):
out_filename = recipe.replace('.py', '.out')
if os.path.isfile(out_filename):
os.remove(out_filename)
Expand Down
2 changes: 1 addition & 1 deletion docs/index_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ echo "STARTING : `date`"

# check existence of taxcalc package
conda list taxcalc | awk '$1~/taxcalc/{rc=1}END{exit(rc)}'
if [ $? -eq 0 ]; then
if [[ $? -eq 0 ]]; then
echo "ERROR: taxcalc package does not exist"
exit 1
fi
Expand Down
Loading

0 comments on commit 4d89d86

Please sign in to comment.