Skip to content

Commit a940ffa

Browse files
committed
Added starter files
1 parent 2d75bd0 commit a940ffa

18 files changed

+73390
-2
lines changed

Playground.ipynb

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"metadata": {
3+
"kernelspec": {
4+
"name": "python3",
5+
"display_name": "Python 3",
6+
"language": "python"
7+
}
8+
},
9+
"nbformat": 4,
10+
"nbformat_minor": 1,
11+
"cells": [
12+
{
13+
"cell_type": "code",
14+
"execution_count": 0,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"import geopandas as gpd\n",
19+
"import pandas as pd\n",
20+
"import matplotlib.pyplot as plt\n",
21+
"\n",
22+
"SHAPE_FILE = '/course/food_access/tl_2010_53_tract00/tl_2010_53_tract00.shp'\n",
23+
"FOOD_ACCESS_FILE = '/course/food_access/food_access.csv'"
24+
]
25+
}
26+
]
27+
}

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# hw5
2-
1+
This repo has starter code for a CSE 163 assignment run in GitHub classroom.

cse163_imgd.py

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""
2+
Ryan Siu
3+
Runs imgd with student output against expected output
4+
and produces images showing the pixel differences.
5+
"""
6+
import subprocess
7+
import os
8+
9+
import hw5
10+
11+
PLOTS = [
12+
"map.png",
13+
"population_map.png",
14+
"county_population_map.png",
15+
"county_food_access.png",
16+
"low_access.png"
17+
]
18+
IMGD_ARGS = [
19+
"--pixel-correct-threshold", "0.985",
20+
"--diff-mode", "always",
21+
"--correct-colour", "ffffff",
22+
]
23+
24+
25+
def run_imgd(expected, actual, args=IMGD_ARGS):
26+
"""
27+
Runs imgd of student output against expected.
28+
Produces diff image only if both student and expected output exist.
29+
"""
30+
if not os.path.exists(actual):
31+
print(f"Could not find the file: {actual} after running hw5.py\n"
32+
"Make sure to call all plotting functions in your main method!")
33+
elif not os.path.exists(expected):
34+
print(f"Could not find the file: {expected}\n")
35+
else:
36+
print(f"Running image comparison tool on {actual}...")
37+
output = subprocess.run(["/opt/ed/bin/imgd", expected, actual]
38+
+ args, capture_output=True)
39+
output = output.stdout.decode("utf-8")
40+
print(output)
41+
os.rename("diff.png", f"{os.path.splitext(actual)[0]}_diff.png")
42+
43+
44+
def main():
45+
print("Running hw5.main(). This may take a few seconds")
46+
hw5.main()
47+
print()
48+
for plot_name in PLOTS:
49+
run_imgd(f"expected/{plot_name}", plot_name)
50+
51+
52+
if __name__ == "__main__":
53+
main()

expected/county_food_access.png

230 KB
Loading

expected/county_population_map.png

52.5 KB
Loading

expected/low_access.png

79.5 KB
Loading

expected/map.png

81 KB
Loading

expected/population_map.png

79.5 KB
Loading

food_access/food_access.csv

+72,865
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ISO-8859-1
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
Binary file not shown.

food_access/tl_2010_53_tract00/tl_2010_53_tract00.shp.xml

+400
Large diffs are not rendered by default.
Binary file not shown.

hw5-writeup.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Food Desert Analysis
2+
3+
## What is one way that government officials could use `plot_food_access_by_county` or `plot_low_access_tracts` to shape public policy on how to improve food access?
4+
5+
6+
7+
## What is a limitation or concern with using the plots in this way?
8+
9+

hw5.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def main():
2+
state_data = load_in_data(
3+
'food_access/tl_2010_53_tract00/tl_2010_53_tract00.shp',
4+
'food_access/food_access.csv'
5+
)
6+
print(percentage_food_data(state_data))
7+
plot_map(state_data)
8+
plot_population_map(state_data)
9+
plot_population_county_map(state_data)
10+
plot_food_access_by_county(state_data)
11+
plot_low_access_tracts(state_data)
12+
13+
14+
if __name__ == '__main__':
15+
main()

pyproject.toml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[tool.poetry]
2+
name = "cse163-hw5"
3+
version = "0.1.0"
4+
description = "Test starter code for CSE 163 - HW5"
5+
authors = ["Hunter Schafer <[email protected]>"]
6+
7+
[tool.poetry.dependencies]
8+
python = "^3.8"
9+
flake8 = "3.8.4"
10+
geopandas = "0.9.0"
11+
matplotlib = "3.4.2"
12+
13+
[tool.poetry.dev-dependencies]
14+
pytest = "^5.2"
15+
16+
[build-system]
17+
requires = ["poetry-core>=1.0.0"]
18+
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)