Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pbnjam-es committed Feb 28, 2023
1 parent f5a566f commit 9cf840f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ examples/*out
NC_ensemble_10000

debug.py

maryland
new_hampshire
1 change: 1 addition & 0 deletions rba/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
arguments["graph_file"] = os.path.join(package_dir, f"data/2010/{state}_geodata_merged.json")
arguments["difference_file"] = os.path.join(package_dir, f"data/2010/{state}_communities.json")
arguments["district_file"] = os.path.join(package_dir, f"data/2010/{state}_districts.json")
# arguments["district_file"] = os.path.join(package_dir, f"../{state}_optimize_10000/Plan_1.json")
elif args.func.__name__ == "visualize":
arguments["graph_file"] = os.path.join(package_dir, f"data/2010/{state}_geodata_merged.json")
arguments["difference_file"] = os.path.join(package_dir, f"data/2010/{state}_communities.json")
Expand Down
4 changes: 3 additions & 1 deletion rba/district_quantification.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def quantify_districts(graph_file, district_file, difference_file, verbose=False
with open(graph_file, "r") as f:
graph_json = json.load(f)
graph = nx.readwrite.json_graph.adjacency_graph(graph_json)
districts = load_districts(graph, district_file)
# districts = load_districts(graph, district_file)
with open(district_file, "r") as f:
districts = json.load(f)

with open(difference_file, "r") as f:
supercommunity_output = json.load(f) # Contains strings as keys.
Expand Down
4 changes: 2 additions & 2 deletions rba/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ def ensemble_analysis(graph_file, difference_file, vra_config_file, num_steps, n
for precinct in precincts:
districts_precinct_df.loc[precinct] = [district_scores[district], homogeneity]

if optimize_vis:
output_dir = vis_dir
# Save a histogram of statewide scores.
plt.hist(scores_df["state_gerry_score"], bins=30)
plt.axvline(scores_df["state_gerry_score"].mean(), color='k', linestyle='dashed', linewidth=1)
Expand All @@ -463,8 +465,6 @@ def get_z_score(precinct, metric):
districts_partition = Partition(graph, assignment=districts_assignment)

# TODO: this doesn't work with Maryland for some reason
if optimize_vis:
output_dir = vis_dir
_, ax = plt.subplots(figsize=(12.8, 9.6))
visualize_gradient_geopandas(
sorted_node_names,
Expand Down

0 comments on commit 9cf840f

Please sign in to comment.