Skip to content

Commit

Permalink
Update environment and several cookbook recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Sep 8, 2018
1 parent 46cb006 commit 2ae992d
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ tctest: package

TAXCALC_JSON_FILES := $(shell ls -l ./taxcalc/*json | awk '{print $$9}')
TESTS_JSON_FILES := $(shell ls -l ./taxcalc/tests/*json | awk '{print $$9}')
PYLINT_OPTIONS = --disable=locally-disabled --score=no --jobs=4
PYLINT_FILES := $(shell grep -rl --include="*py" disable=locally-disabled .)

.PHONY=cstest
Expand All @@ -79,7 +80,7 @@ cstest:
pycodestyle docs/cookbook
@pycodestyle --ignore=E501,E121 $(TAXCALC_JSON_FILES)
@pycodestyle --ignore=E501,E121 $(TESTS_JSON_FILES)
@pylint --disable=locally-disabled --score=no --jobs=4 $(PYLINT_FILES)
@pylint $(PYLINT_OPTIONS) $(PYLINT_FILES)

define coverage-cleanup
rm -f .coverage htmlcov/*
Expand Down
7 changes: 3 additions & 4 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ requirements:
- python
- numpy >=1.12.1
- pandas >=0.22.0
- bokeh >=0.12.3
- numba
- toolz
- six
- bokeh >=0.12.3

run:
- python
- numpy >=1.12.1
- pandas >=0.22.0
- bokeh >=0.12.3
- numba
- toolz
- six
- bokeh >=0.12.3

test:
commands:
Expand Down
4 changes: 2 additions & 2 deletions docs/cookbook.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ <h1 id="toc">Cookbook of Tested Recipes for Python Programming with
<p>This document tells you how to use Tax-Calculator, an open-source
federal income and payroll tax simulation model, in Python scripts
that you can run on your own computer. Note that these recipes
require Tax-Calculator release 0.20.1 or higher. For other ways of
using Tax-Calculator, see the
require Tax-Calculator release 0.21.0 or higher running on Python 3.6.
For other ways of using Tax-Calculator, see the
<a href="https://open-source-economics.github.io/Tax-Calculator/">
user documentation</a>, which this Cookbook assumes you have read.</p>

Expand Down
4 changes: 2 additions & 2 deletions docs/cookbook/recipe03.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
tot_recips = 0.
tot_amount = 0.
idx = 0
for gname, grp in gbydf:
for grp_interval, grp in gbydf:
recips = grp[grp['eitc'] > 0]['s006'].sum() * 1e-6
tot_recips += recips
amount = (grp['eitc'] * grp['s006']).sum() * 1e-9
Expand All @@ -36,7 +36,7 @@
avg = amount / recips
else:
avg = np.nan
glabel = '[{:.8g}, {:.8g})'.format(gname.left, gname.right)
glabel = '[{:.8g}, {:.8g})'.format(grp_interval.left, grp_interval.right)
print(results.format(glabel, recips, avg))
idx += 1
avg = tot_amount / tot_recips
Expand Down
4 changes: 2 additions & 2 deletions docs/cookbook/recipe04.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
tot_response = 0.
tot_baseline = 0.
idx = 0
for gname, grp in gbydf:
for grp_interval, grp in gbydf:
funits = grp['s006'].sum() * 1e-6
tot_funits += funits
response = quantity_response(grp['e19800'],
Expand All @@ -75,7 +75,7 @@
grp_baseline = (grp['e19800'] * grp['s006']).sum() * 1e-9
tot_baseline += grp_baseline
pct_response = 100. * grp_response / grp_baseline
glabel = '[{:.8g}, {:.8g})'.format(gname.left, gname.right)
glabel = '[{:.8g}, {:.8g})'.format(grp_interval.left, grp_interval.right)
print(results.format(glabel, funits, grp_response, pct_response))
idx += 1
pct_response = 100. * tot_response / tot_baseline
Expand Down
10 changes: 5 additions & 5 deletions docs/recipe00.graph.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/recipe03.py.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
tot_recips = 0.
tot_amount = 0.
idx = 0
for gname, grp in gbydf:
for grp_interval, grp in gbydf:
recips = grp[grp['eitc'] > 0]['s006'].sum() * 1e-6
tot_recips += recips
amount = (grp['eitc'] * grp['s006']).sum() * 1e-9
Expand All @@ -37,7 +37,7 @@
avg = amount / recips
else:
avg = np.nan
glabel = '[{:.8g}, {:.8g})'.format(gname.left, gname.right)
glabel = '[{:.8g}, {:.8g})'.format(grp_interval.left, grp_interval.right)
print(results.format(glabel, recips, avg))
idx += 1
avg = tot_amount / tot_recips
Expand Down
4 changes: 2 additions & 2 deletions docs/recipe04.py.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
tot_response = 0.
tot_baseline = 0.
idx = 0
for gname, grp in gbydf:
for grp_interval, grp in gbydf:
funits = grp['s006'].sum() * 1e-6
tot_funits += funits
response = quantity_response(grp['e19800'],
Expand All @@ -76,7 +76,7 @@
grp_baseline = (grp['e19800'] * grp['s006']).sum() * 1e-9
tot_baseline += grp_baseline
pct_response = 100. * grp_response / grp_baseline
glabel = '[{:.8g}, {:.8g})'.format(gname.left, gname.right)
glabel = '[{:.8g}, {:.8g})'.format(grp_interval.left, grp_interval.right)
print(results.format(glabel, funits, grp_response, pct_response))
idx += 1
pct_response = 100. * tot_response / tot_baseline
Expand Down
3 changes: 1 addition & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ name: taxcalc-dev
dependencies:
- numpy >=1.12.1
- pandas >=0.22.0
- bokeh >=0.12.3
- numba
- toolz
- six
- bokeh >=0.12.3
- mock
- pep8
- pycodestyle
Expand Down
7 changes: 4 additions & 3 deletions taxcalc/tests/test_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def comparison(cname, calc, cmpdata, ofile):
txc_tot = 0.
soi_tot = 0.
idx = 0
for gname, grp in gbydf:
for grp_interval, grp in gbydf:
txc = (grp['cvar'] * grp['s006']).sum() * 1e-9
soi = cmpdata[cname]['SOI'][idx]
txc_tot += txc
Expand All @@ -221,8 +221,9 @@ def comparison(cname, calc, cmpdata, ofile):
pct_diff = 100. * ((txc / soi) - 1.)
else:
pct_diff = np.nan
grplabel = '[{:.8g}, {:.8g})'.format(gname.left, gname.right)
ofile.write(results.format(grplabel, txc, soi, pct_diff))
glabel = '[{:.8g}, {:.8g})'.format(grp_interval.left,
grp_interval.right)
ofile.write(results.format(glabel, txc, soi, pct_diff))
idx += 1
pct_diff = 100. * ((txc_tot / soi_tot) - 1.)
ofile.write(results.format('ALL', txc_tot, soi_tot, pct_diff))
Expand Down

0 comments on commit 2ae992d

Please sign in to comment.