Skip to main content

Use Markov chain Monte Carlo to analyze districting plans and gerrymanders

Project description

Build Status Code Coverage Documentation Status PyPI Package conda-forge Package

GerryChain is a Python library for building ensembles of districting plans using Markov chain Monte Carlo. It is developed and maintained by the Metric Geometry and Gerrymandering Group and our network of volunteers. It is distributed under the 3-Clause BSD License.

The basic workflow is to start with the geometry of an initial plan and generate a large collection of sample plans for comparison. Usually, we will constrain these sampled plans in such a way that they perform at least as well as the initial plan according to traditional districting principles, such as population balance or compactness. Comparing the initial plan to the ensemble provides quantitative tools for measuring whether or not it is an outlier among the sampled plans.

Getting started

See our Getting started guide for the basics of using GerryChain.

We also highly recommend the resources prepared by Daryl R. DeFord of MGGG for the 2019 MIT IAP course Computational Approaches for Political Redistricting.

Installation

Using pip

To install GerryChain from PyPI, run pip install gerrychain from the command line.

If you plan on using GerryChain’s GIS functions, such as computing adjacencies or reading in shapefiles, then run pip install gerrychain[geo] from the command line.

This approach sometimes fails due to compatibility issues between our different Python GIS dependencies, like geopandas, pyproj, fiona, and shapely. For this reason, we recommend installing from conda-forge for users that encounter difficulty with PyPI.

Using conda

To install GerryChain from conda-forge using conda, run

conda install -c conda-forge gerrychain

For this command to work as intended, you will first need to activate the conda environment that you want to install GerryChain in. If the environment you want to activate is called vrdi (for example), then you can do this by running

conda activate vrdi

If this command causes problems, make sure conda is up-to-date by running

conda update conda
conda init

For more information on using conda to install packages and manage dependencies, see Getting started with conda.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gerrychain-0.2.22.tar.gz (70.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gerrychain-0.2.22-py2.py3-none-any.whl (58.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file gerrychain-0.2.22.tar.gz.

File metadata

  • Download URL: gerrychain-0.2.22.tar.gz
  • Upload date:
  • Size: 70.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for gerrychain-0.2.22.tar.gz
Algorithm Hash digest
SHA256 edb64358681850c408140d9a0fec11358f8395eda59d46b8a09e9ffdba9724fc
MD5 451924c691c390fbb74ee052d1e3d01b
BLAKE2b-256 5ef64d8e744bc1ef5cf1c96a53b6f3e39b7f432d05ea3e15dcba8282f54aa33a

See more details on using hashes here.

File details

Details for the file gerrychain-0.2.22-py2.py3-none-any.whl.

File metadata

  • Download URL: gerrychain-0.2.22-py2.py3-none-any.whl
  • Upload date:
  • Size: 58.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for gerrychain-0.2.22-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a18f3c53da804cb3c5720f2a06972e9458a5fa220111e5c191560c481eea587f
MD5 b9f89f4fb478f6ac09e095481d8240ac
BLAKE2b-256 e293f090348683c4bfe72903c071540e8fc8473579dff232e9a4ed2009b5eeb3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page