#compression #parser #redistricting

app pcompress

Experimental, efficient, and performant binary representation of districting plans

7 releases (3 stable)

1.0.3 Oct 4, 2021
1.0.2 Sep 23, 2021
1.0.0 Aug 29, 2021
0.2.2 Aug 25, 2021
0.1.1 Aug 25, 2021

#40 in Compression

43 downloads per month

MIT license

206 lines


Currently it is hard to store the state of every single step of a normal Markov Chain Monte Carlo from GerryChain Python or GerryChain Julia. This repo aims to produce an efficient intermediate binary representation of partitions/districting assignments that will enable for generated plans to be saved on-the-fly. Each step is represented as the diff from the previous step, enabling a significant reduction in disk usage per step.


cargo install pcompress
pip install pcompress

Python Usage

Note that chain is a normal MarkovChain object and graph is a normal GerryChain graph.


from pcompress import Record

for partition in Record(chain, "pa-run.chain"):
    # normal chain stuff here


from pcompress import Record

for partition in Replay(graph, "pa-run.chain", updaters=my_updaters):
   # normal chain stuff here


~55K SLoC