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 violin plotting function #357

Merged
merged 4 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 0 additions & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ coverage:
- "tools/*"
- "geosnap/tests/*"
- "geosnap/util/*"
- "geosnap/visualize/commviz.py"
- "geosnap/visualize/viz.py"
- "geosnap/io/util.py"
- "geosnap/_version.py"
comment:
Expand Down
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ Visualize Module
visualize.plot_timeseries
visualize.plot_transition_matrix
visualize.plot_transition_graphs
visualize.plot_violins_by_cluster

.. _util_api:

Expand Down
6 changes: 2 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- libpysal
- cenpy
- geopandas >=0.9
- matplotlib
- matplotlib <=3.3.4 # workaround for proplot missing pin upstream
- scikit-learn
- seaborn
- pyarrow >=0.14.1
Expand All @@ -28,6 +28,4 @@ dependencies:
- versioneer
- pyproj >=3
- pandana
- pip
- pip:
- -e . # install local geosnap package in editable mode
- pooch
6 changes: 3 additions & 3 deletions geosnap/io/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import pathlib
import pooch
from urllib.error import HTTPError
from warnings import warn

Expand Down Expand Up @@ -40,9 +41,8 @@ def get_census_gdb(years=None, geom_level="blockgroup", output_dir="."):
fn = f"{year}_ACS_5YR_{geom_level.capitalize()}.gdb.zip"
out_fn = f"ACS_{year}_5YR_{levels[geom_level].upper()}.gdb.zip"
pth = pathlib.PurePath(output_dir, out_fn)
url = f"ftp://ftp2.census.gov/geo/tiger/TIGER_DP/{year}ACS/{fn}"
download(url, pth)

url = f"https://www2.census.gov/geo/tiger/TIGER_DP/{year}ACS/{fn}"
pooch.retrieve(url, None, progressbar=True, path=pth)

def reformat_acs_vars(col):
"""Convert variable names to the same format used by the Census Detailed Tables API.
Expand Down
9 changes: 8 additions & 1 deletion geosnap/tests/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
plot_timeseries,
plot_transition_graphs,
plot_transition_matrix,
plot_violins_by_cluster
)


Expand Down Expand Up @@ -71,9 +72,15 @@ def test_graphs():
def test_animation():
if not os.path.exists('geosnap/tests/images'):
os.mkdir('geosnap/tests/images')
animate_timeseries(dc_df, column='ward', categorical=True, filename='geosnap/tests/images/animation.gif')
animate_timeseries(dc_df, column='ward', categorical=True, filename='geosnap/tests/images/animation.gif', dpi=50)
assert 'animation.gif' in os.listdir('geosnap/tests/images')

def test_violins():
if not os.path.exists('geosnap/tests/images'):
os.mkdir('geosnap/tests/images')
plot_violins_by_cluster(dc_df, cluster_col='ward', columns=columns, savefig='geosnap/tests/images/violins.png', dpi=50)
assert 'violins.png' in os.listdir('geosnap/tests/images')

def test_boundary_silplot():
p = region_mod[1990].plot_boundary_silhouette(dpi=50,)
assert isinstance(p, proplot.gridspec.SubplotGrid
Expand Down
4 changes: 2 additions & 2 deletions geosnap/visualize/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .seq import *
from .commviz import explore
from .transitions import *
from .mapping import *
from .mapping import *
from .descriptives import *
Loading