mggg / GerryChain

Use MCMC to analyze districting plans and gerrymanders
https://mggg.github.io/GerryChain/
Other
132 stars 74 forks source link

Fix uniform spanning tree choice func #401

Closed InnovativeInventor closed 2 years ago

InnovativeInventor commented 2 years ago

This PR actually fixes two bugs. First of all, since node_indices is a set, random.choice does not work on it (unless it's first cast to a list). Secondly, sometimes a pure networkx graph is passed to PopulationGraph, so we cannot assume that the node_indicies property exists.

codecov[bot] commented 2 years ago

Codecov Report

Merging #401 (c09a07b) into main (b1823d0) will increase coverage by 1.12%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #401      +/-   ##
==========================================
+ Coverage   87.97%   89.10%   +1.12%     
==========================================
  Files          39       39              
  Lines        1772     1772              
==========================================
+ Hits         1559     1579      +20     
+ Misses        213      193      -20     
Impacted Files Coverage Δ
gerrychain/partition/partition.py 95.60% <100.00%> (+3.29%) :arrow_up:
gerrychain/tree.py 82.49% <100.00%> (+6.61%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b1823d0...c09a07b. Read the comment docs.

gabeschoenbach commented 2 years ago

This looks great! I'll merge it in.