Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MTR Plotting #948

Merged
merged 38 commits into from
Oct 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7827df2
generalize add_weighted_decile_bins
GoFroggyRun Sep 23, 2016
289c9b6
test modified
GoFroggyRun Sep 23, 2016
245539c
get_data_mtr
GoFroggyRun Sep 26, 2016
b779bda
typo
GoFroggyRun Sep 26, 2016
9a06bcc
styles added
GoFroggyRun Sep 26, 2016
b4bd533
add plot function
GoFroggyRun Sep 26, 2016
7d9c905
add test suite
GoFroggyRun Sep 26, 2016
58fbfa5
add document
GoFroggyRun Sep 26, 2016
7f45536
conflicts
GoFroggyRun Sep 26, 2016
9751f25
PEP8
GoFroggyRun Sep 26, 2016
c7700ed
rm styles.py, and used simple color potions
GoFroggyRun Oct 4, 2016
04d591d
add bokeh to all test yml
GoFroggyRun Oct 4, 2016
eeb3d27
order matters?
GoFroggyRun Oct 4, 2016
1d91216
records_2009 instead of TAXDATA
GoFroggyRun Oct 4, 2016
e326f43
more tests
GoFroggyRun Oct 4, 2016
bb6ef97
Merge branch 'mtr_plot' of github.com:GoFroggyRun/Tax-Calculator into…
Oct 5, 2016
ab3c5f5
try/except on import of bokeh
Oct 5, 2016
dcfcd07
Merge pull request #1 from talumbau/sean_mtr_bokeh
GoFroggyRun Oct 5, 2016
0f7e9b2
Removed Two Un-supported Groupby
GoFroggyRun Oct 7, 2016
483cba2
output_file under command line
GoFroggyRun Oct 7, 2016
a953809
PEP8 and more docs
GoFroggyRun Oct 7, 2016
df58a47
Import output_file, show
GoFroggyRun Oct 11, 2016
db5cad0
fixed document typo, and deprecation error
GoFroggyRun Oct 11, 2016
5c1256d
_combined instead of combined in test suite
GoFroggyRun Oct 11, 2016
b41a061
partially revert deprecation fix
GoFroggyRun Oct 12, 2016
deecd73
modified documentation for weighting options
GoFroggyRun Oct 17, 2016
b2e09dd
test_suite change
GoFroggyRun Oct 17, 2016
4723564
weighting of string type
GoFroggyRun Oct 18, 2016
fb55493
modify test suite
GoFroggyRun Oct 18, 2016
fc83012
forgot to update '_iitax' case
GoFroggyRun Oct 18, 2016
0d512d9
update test suite
GoFroggyRun Oct 18, 2016
890545e
Merge remote-tracking branch 'upstream/master' into mtr_plot
GoFroggyRun Oct 19, 2016
829bbb9
more documentation
GoFroggyRun Oct 20, 2016
0d458e0
complex weight doc
GoFroggyRun Oct 20, 2016
25d7c5d
document and NA
GoFroggyRun Oct 21, 2016
94bf8e1
name change
GoFroggyRun Oct 21, 2016
e382239
more docstring
GoFroggyRun Oct 24, 2016
89bbd48
swtiched order
GoFroggyRun Oct 25, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ install:
- export PATH="$HOME/miniconda/bin:$PATH"
- conda config --set always_yes yes --set changeps1 no
- conda update conda
- conda create -n taxcalcdev python=$TRAVIS_PYTHON_VERSION pytest setuptools pandas=0.18 toolz six mock
- conda create -n taxcalcdev python=$TRAVIS_PYTHON_VERSION pytest setuptools pandas=0.18 toolz six mock bokeh
- source activate taxcalcdev
- if [ $TRAVIS_EVENT_TYPE != 'cron' ]; then conda install numba; fi
- pip install pytest-pep8
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies:
- numpy =1.10.4
- pandas =0.18.0
- numba
- bokeh
- toolz
- six
- ipython
Expand Down
39 changes: 36 additions & 3 deletions taxcalc/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,14 @@ def test_add_income_bins_raises():

def test_add_weighted_decile_bins():
df = DataFrame(data=data, columns=['_expanded_income', 's006', 'label'])
df = add_weighted_decile_bins(df)
assert 'bins' in df
df = add_weighted_decile_bins(df, num_bins=100)
bin_labels = df['bins'].unique()
default_labels = set(range(1, 11))
default_labels = set(range(1, 101))
for lab in bin_labels:
assert lab in default_labels
# Custom labels
df = add_weighted_decile_bins(df, weight_by_income_measure=True)
assert 'bins' in df
custom_labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
df = add_weighted_decile_bins(df, labels=custom_labels)
assert 'bins' in df
Expand Down Expand Up @@ -516,6 +517,38 @@ def test_expand_2D_accept_None_additional_row():
npt.assert_allclose(pol.II_brk2, exp_2020)


def test_get_mtr_data(records_2009):
pol = Policy()
behv = Behavior()
calc = Calculator(policy=pol, records=records_2009, behavior=behv)
calc.calc_all()
source = get_mtr_data(calc, calc, MARS=1, mtr_measure='_combined')


def test_mtr_plot(records_2009):
pol = Policy()
behv = Behavior()
calc = Calculator(policy=pol, records=records_2009, behavior=behv)
calc.calc_all()
source = get_mtr_data(calc, calc, weighting='wage_weighted',
weight_by_income_measure=True)
plot = mtr_plot(source)


def test_mtr_plot_force_no_bokeh(records_2009):
import taxcalc
taxcalc.utils.BOKEH_AVAILABLE = False
pol = Policy()
behv = Behavior()
calc = Calculator(policy=pol, records=records_2009, behavior=behv)
calc.calc_all()
source = get_mtr_data(calc, calc, weighting='weighted_mean',
weight_by_income_measure=True)
with pytest.raises(RuntimeError):
plot = mtr_plot(source)
taxcalc.utils.BOKEH_AVAILABLE = True


def test_multiyear_diagnostic_table(records_2009):
pol = Policy()
behv = Behavior()
Expand Down
Loading