Skip to content

Commit

Permalink
Merge pull request #192 from jdebacker/pd_updates
Browse files Browse the repository at this point in the history
Updates for newer versions of dependencies
  • Loading branch information
jdebacker authored Feb 22, 2024
2 parents 2c63597 + 724b487 commit d3367c8
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 27 deletions.
32 changes: 26 additions & 6 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
name: Build Package and Test Source Code [Python 3.7, 3.8]
name: Build Package and Test Source Code [Python 3.9, 3.10, 3.11]

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.7, 3.8]
os: [ubuntu-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: Checkout
uses: actions/checkout@master
with:
persist-credentials: false
- name: Setup TeX Live
uses: teatimeguest/setup-texlive-action@v3
with:
packages: >-
scheme-basic
cleveref
hyperref
iftex
listings
fancyvrb
longtable
booktabs
graphicx
bookmark
xcolor
soul
geometry
setspace
babel
etoolbox
footnote
- name: Setup Miniconda using Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
Expand All @@ -24,8 +46,6 @@ jobs:
- name: Build
shell: bash -l {0}
run: |
sudo apt update
sudo apt-get install texlive texlive-latex-extra
pip install -e .
pip install pytest-cov
pip install pytest-pycodestyle
Expand All @@ -35,7 +55,7 @@ jobs:
run: |
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
file: ./coverage.xml
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/check_jupyterbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ jobs:
with:
activate-environment: taxbrain-dev
environment-file: environment.yml
python-version: 3.7
python-version: "3.10"
auto-activate-base: false

- name: Build # Build Jupyter Book
shell: bash -l {0}
run: |
pip install jupyter-book
pip install -e .
python -m ipykernel install --user --name=taxbrain-dev
cd docs
jb build ./book
5 changes: 3 additions & 2 deletions .github/workflows/deploy_jupyterbook.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build and Deploy Jupyter Book
on:
push:
branches:
branches:
- master
jobs:
build-and-deploy:
Expand All @@ -18,14 +18,15 @@ jobs:
with:
activate-environment: taxbrain-dev
environment-file: environment.yml
python-version: 3.7
python-version: "3.10"
auto-activate-base: false

- name: Build # Build Jupyter Book
shell: bash -l {0}
run: |
pip install jupyter-book
pip install -e .
python -m ipykernel install --user --name=taxbrain-dev
cd docs
jb build ./book
Expand Down
2 changes: 1 addition & 1 deletion cs-config/cs_config/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def arbitrary_defaultdict():
# format table
for col in tbl.columns:
if col in MONEY_VARS:
tbl.update(tbl[col].apply("${:,.2f}".format))
tbl[col] = tbl[col].apply("${:,.2f}".format)

tags = RESULTS_TABLE_TAGS[id]
tbl_type = tags["table_type"]
Expand Down
16 changes: 8 additions & 8 deletions cs-config/cs_config/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
from bokeh.models import (ColumnDataSource, Toggle, CustomJS,
NumeralTickFormatter, HoverTool)
from bokeh.models.widgets import Tabs, Panel, Div
from bokeh.models import TabPanel, Tabs, Div
from bokeh.embed import json_item
from bokeh.layouts import layout
from bokeh.plotting import figure
Expand Down Expand Up @@ -127,11 +127,11 @@ def create_layout(data, start_year, end_year):
change_table = Div(text=ct_title + agg_data["change"]["renderable"],
width=1000)

current_tab = Panel(child=current_law_table,
current_tab = TabPanel(child=current_law_table,
title="Current Law")
reform_tab = Panel(child=reform_table,
reform_tab = TabPanel(child=reform_table,
title="Reform")
change_tab = Panel(child=change_table,
change_tab = TabPanel(child=change_table,
title="Change")
agg_tabs = Tabs(tabs=[current_tab, reform_tab, change_tab])

Expand Down Expand Up @@ -167,20 +167,20 @@ def create_layout(data, start_year, end_year):
"Averages and shares are as shown.</i></p>")
tbl = Div(text=title + note + _data["renderable"],
width=1000)
grp_panel = Panel(child=tbl, title=grp.title())
grp_panel = TabPanel(child=tbl, title=grp.title())
grp_panels.append(grp_panel)
grp_tab = Tabs(tabs=grp_panels)
# panel for the sub tables
content_panel = Panel(child=grp_tab, title=key_map[key])
content_panel = TabPanel(child=grp_tab, title=key_map[key])
content_panels.append(content_panel)
content_tab = Tabs(tabs=content_panels)
# panel for the table types
tbl_panel = Panel(child=content_tab,
tbl_panel = TabPanel(child=content_tab,
title=key_map[tbl_type])
tbl_panels.append(tbl_panel)
type_tab = Tabs(tabs=tbl_panels)
# panel for the year
yr_panel = Panel(child=type_tab, title=str(yr))
yr_panel = TabPanel(child=type_tab, title=str(yr))
yr_panels.append(yr_panel)

yr_tabs = Tabs(tabs=yr_panels)
Expand Down
6 changes: 4 additions & 2 deletions docs/book/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Book settings
title : Tax-Brain
author : Anderson Frailey
copyright : '2021'
copyright : '2024'
logo : '../taxbrain.png'

####################################################
Expand Down Expand Up @@ -42,7 +42,7 @@ launch_buttons:
# Information about where the book exists on the web
repository:
url : https://github.com/PSLmodels/Tax-Brain
path_to_book : 'book'
path_to_book : 'docs/book'

#######################################################################################
# Advanced and power-user settings
Expand All @@ -51,6 +51,8 @@ sphinx:
'sphinx.ext.viewcode', 'sphinx.ext.napoleon',
'alabaster'] # A list of extra extensions to load by Sphinx.
config : # key-value pairs to directly over-ride the Sphinx configuration
bibtex_reference_style: author_year
mathjax_path : https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js

####################################################
# LaTeX information
Expand Down
7 changes: 4 additions & 3 deletions taxbrain/report.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import shutil
import pandas as pd
import behresp
import taxbrain
import taxcalc as tc
Expand Down Expand Up @@ -178,9 +179,9 @@ def export_plot(plot, graph):
tb.start_year, "weighted_deciles", "combined"
).fillna(0)
# move the "ALL" row to the bottom of the DataFrame
row = decile_diff_table.loc["ALL"].copy()
decile_diff_table.drop("ALL", inplace=True)
decile_diff_table = decile_diff_table.append(row)
target_row = decile_diff_table.loc["ALL", :]
decile_diff_table = decile_diff_table.shift(-1)
decile_diff_table.iloc[-1] = target_row.squeeze()

# find which income bin sees the largest change in tax liability
largest_change = largest_tax_change(diff_table)
Expand Down
6 changes: 3 additions & 3 deletions taxbrain/tests/expected_weighted_table.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
,2018,2019
Base,2337568822215.7954,2466063728525.13
Reform,2337568822215.7954,2498202959697.5903
Difference,0.0,32139231172.46045
Base,2333219200997.7583,2453853281529.6304
Reform,2333219200997.7583,2485749384352.428
Difference,0.0,31896102822.79785
2 changes: 1 addition & 1 deletion taxbrain/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def lorenz_data(tb, year: int, var: str = "aftertax_income"):
# each bin has 1% of the population
_bins = np.arange(0, 1.01, step=0.01)
data["bin"] = pd.cut(data['percentile'], bins=_bins)
gdf = data.groupby("bin")
gdf = data.groupby("bin", observed=False)
base = gdf["wt_base"].sum()
base = np.where(base < 0, 0, base)
reform = gdf["wt_reform"].sum()
Expand Down

0 comments on commit d3367c8

Please sign in to comment.