diff --git a/read-the-docs/notebooks/10_Minutes_to_Tax-Calculator.ipynb b/read-the-docs/notebooks/10_Minutes_to_Tax-Calculator.ipynb deleted file mode 100644 index f1adaeb73..000000000 --- a/read-the-docs/notebooks/10_Minutes_to_Tax-Calculator.ipynb +++ /dev/null @@ -1,198 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# How to use Tax-Calculator" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This guide teaches you how to use Tax-Calculator. To follow along you will need the following: \n", - "\n", - "1. A copy of the taxcalc package installed on your local machine.\n", - "2. A copy of the puf.csv file output from the TaxData repository. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Import taxcalc package and other useful packages" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "import sys\n", - "sys.path.append(\"../../\")\n", - "from taxcalc import *" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create Plan X and Plan Y Policy objects containing current law policy and then implement reforms" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "# The baseline includes AMT repeal. \n", - "p_xx = Policy()\n", - "reform_xx = {\n", - " 2017: {\n", - " '_AMT_rt1': [0.0],\n", - " '_AMT_rt2': [0.0]\n", - " }\n", - "}\n", - "p_xx.implement_reform(reform_xx)\n", - "\n", - "# The reform expands the second tax bracket\n", - "# (and repeals AMT to match the baseline)\n", - "\n", - "p_yy = Policy()\n", - "reform_yy = {\n", - " 2017: {\n", - " '_II_brk2': [[65005, 130010, 65005, 88180, 0]],\n", - " '_AMT_rt1': [0.0],\n", - " '_AMT_rt2': [0.0]\n", - " }\n", - "}\n", - "p_yy.implement_reform(reform_yy)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create calculator objects with default tax data\n", - "###### The data are automatically extrapolated to 2013 since that is the first tax year modeled by Tax-Calculator. " - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You loaded data for 2009.\n", - "Tax-Calculator startup automatically extrapolated your data to 2013.\n", - "You loaded data for 2009.\n", - "Tax-Calculator startup automatically extrapolated your data to 2013.\n" - ] - } - ], - "source": [ - "c_xx = Calculator(policy=p_xx, records=Records(\"../../puf.csv\"))\n", - "c_yy = Calculator(policy=p_yy, records=Records(\"../../puf.csv\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Advance the calculator objects to 2017 for this analysis. " - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "c_xx.advance_to_year(2017)\n", - "c_yy.advance_to_year(2017)\n", - "assert c_xx.current_year == 2017\n", - "assert c_yy.current_year == 2017\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Calculate taxes under the baseline and under the reform. " - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "c_xx.calc_all()\n", - "c_yy.calc_all()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Calculate the change in combined payroll and individual income tax revenue between the baseline and reform" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "-102894721202.03145" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "((c_yy.records.combined - c_xx.records.combined)*c_xx.records.s006).sum()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" - } - }, - "nbformat": 4, - "nbformat_minor": 1 -} diff --git a/read-the-docs/source/contributor_guide.rst b/read-the-docs/source/contributor_guide.rst index a7ca35342..1a61aa2d1 100644 --- a/read-the-docs/source/contributor_guide.rst +++ b/read-the-docs/source/contributor_guide.rst @@ -227,9 +227,10 @@ situations, in which case other contributors are here to help. Simple Usage ------------ -For examples of Tax-Calculator usage (without changing tax parameter -values and without adding a new tax parameter), you can view our code -sample notebook: `10 Minutes To Tax-Calculator`_. +For examples of Tax-Calculator usage, see the `Cookbook of Tested +Recipes for Python Programming with Tax-Calculator`_, which contains +Python scripts that can be executed by the Python command-line +interpreter or imported into a Python notebook for interactive execution. .. [1] The dollar sign is the end of the command prompt on a Mac. If @@ -273,14 +274,6 @@ sample notebook: `10 Minutes To Tax-Calculator`_. .. _`Github Flow`: https://guides.github.com/introduction/flow/ -.. _`10 Minutes To Tax-Calculator`: - http://nbviewer.ipython.org/github/open-source-economics/Tax-Calculator/ - blob/master/read-the-docs/notebooks/10_Minutes_to_Tax-Calculator.ipynb - -.. _`Behavior Example`: - http://nbviewer.ipython.org/github/open-source-economics/Tax-Calculator/ - blob/master/read-the-docs/notebooks/Behavioral_example.ipynb - .. _`Continuum Analytics`: http://www.continuum.io/downloads @@ -313,3 +306,6 @@ sample notebook: `10 Minutes To Tax-Calculator`_. .. _`open a pull request`: https://help.github.com/articles/creating-a-pull-request/#creating-the-pull-request + +.. _`Cookbook of Tested Recipes for Python Programming with Tax-Calculator`: + https://github.com/open-source-economics/Tax-Calculator/blob/master/docs/cookbook.html diff --git a/taxcalc/tests/test_notebooks.py b/taxcalc/tests/test_notebooks.py deleted file mode 100644 index ce5da5405..000000000 --- a/taxcalc/tests/test_notebooks.py +++ /dev/null @@ -1,32 +0,0 @@ -# CODING-STYLE CHECKS: -# pycodestyle test_notebooks.py - -import os -import json -import subprocess -import pytest - - -def notebook_run(test_path, notebook_path): - content = [] - for cell in json.load(open(notebook_path))['cells']: - if cell.get('cell_type') == 'code': - content.append('\n'.join(cell['source'])) - script = '\n ## Next Cell ## \n'.join(content) - sfilename = os.path.join(test_path, 'notebook_script.py') - with open(sfilename, 'w') as sfile: - sfile.write(script) - rcode = subprocess.check_call(['python', sfilename], cwd=test_path) - if os.path.exists(sfilename): - os.remove(sfilename) - return rcode - - -@pytest.mark.notebook -@pytest.mark.requires_pufcsv -@pytest.mark.skip -def test_10minutes_notebook(tests_path): - notebook_path = os.path.join(tests_path, '..', '..', - 'read-the-docs', 'notebooks', - '10_Minutes_to_Tax-Calculator.ipynb') - assert notebook_run(tests_path, notebook_path) == 0