mggg / GerryChain

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

Add initial shims #402

Closed InnovativeInventor closed 1 year ago

InnovativeInventor commented 2 years ago

This is a PR to add some shims to alternate implementation/sampling methods. These shims can be called from GerryChain Python and behave as a drop-in replacement for normal chain running. The goal is to add shims for:

Example usage

from gerrychain.shims.frcw import frcw_recom, frcw_reversible_recom

# generate seed partition, etc

for partition in frcw_recom(partition, "TOTPOP", ideal_pop, 0.01, steps=10000):
    # normal chain stuff here
codecov[bot] commented 2 years ago

Codecov Report

Merging #402 (2de9eaa) into main (b1823d0) will decrease coverage by 1.41%. The diff coverage is 0.00%.

:exclamation: Current head 2de9eaa differs from pull request most recent head d2f67f0. Consider uploading reports for the commit d2f67f0 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #402      +/-   ##
==========================================
- Coverage   87.97%   86.56%   -1.42%     
==========================================
  Files          39       42       +3     
  Lines        1772     1801      +29     
==========================================
  Hits         1559     1559              
- Misses        213      242      +29     
Impacted Files Coverage Δ
gerrychain/shims/__init__.py 0.00% <0.00%> (ø)
gerrychain/shims/frcw.py 0.00% <0.00%> (ø)
gerrychain/shims/serialize.py 0.00% <0.00%> (ø)

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...d2f67f0. Read the comment docs.

pjrule commented 1 year ago

Closing this for now—we are planning to provide some form of PyO3 bindings for frcw.rs (indeed, some progress has already been made in this direction), which is significantly less brittle than calling the CLI via subprocess.