Skip to main content

gerrytools

tests PyPI version docs website Code style: Ruff

A companion to GerryChain, GerryTools provides tools for retrieving redistricting data, recording and scoring ensembles, comparing districting plans, and producing publication-ready figures and tables. It is developed by the Data and Democracy Research Initiative and distributed under the 3-Clause BSD License.

Installation

GerryTools requires Python 3.11 or newer. Published wheels include the compiled scoring engine; building from source requires a stable Rust toolchain and a C++ compiler.

To install GerryTools from PyPI, run:

pip install gerrytools

The gerrytools.ben API is included in the base installation. To use the Docker-backed ensemble runners in gerrytools.mgrp, install the optional dependency:

pip install "gerrytools[mgrp]"

The runners also require Docker Desktop, Docker Engine, or another compatible daemon. See the Docker documentation for platform requirements and setup instructions.

Usage

GerryTools is organized into public modules that can be used independently or together:

  • gerrytools.data retrieves decennial Census and American Community Survey tables, estimates block-level citizen voting-age population, and downloads processed 2020 geographic products.

  • gerrytools.plan_comparison compares plans by population or area, finds optimal district relabelings, and measures population dispersion.

  • gerrytools.plotting provides composable statistical and geographic plot builders that work with Matplotlib figures and axes.

  • gerrytools.colors provides named colors, district palettes, color conversion, and Matplotlib and seaborn colormaps.

  • gerrytools.mgrp runs Rust ReCom, Forest ReCom, Sequential Monte Carlo, and optimization workflows through a versioned Docker image.

  • gerrytools.ben records GerryChain runs as self-describing BENDL files and reconstructs recorded partitions for lookup, subsampling, and analysis.

  • gerrytools.scoring prepares graph and geometry resources once, evaluates plans with the compiled Rust scoring engine, and provides one-shot functions and array formulas.

  • gerrytools.latex builds LaTeX documents and tables plus TikZ-native paintball and seats-votes figures.

See the module guides for examples and the API reference for signatures and parameters.

Contributing

GerryTools is an active project, and has multiple contributors. If you'd like to contribute, here are a few house rules:

  1. Install task and uv, then run task setup from the repository root. Use task --list-all to see the available development workflows.

  2. Run task check before opening a pull request. Use task format for Ruff formatting and import sorting, task lint for Ruff linting, task test for the test suite, and task docs to build the documentation locally.

  3. Write tests. All changes, major or minor, must be accompanied by testing code. Code and tests will be immediately reviewed by Lab maintainers.

  4. Test coverage must stay at least the same; this can be checked by running uv run pytest --cov=gerrytools --cov-report=term-missing after the tests are added to tests/.

  5. Write documentation. Document public APIs and non-obvious invariants. Prefer clear names and focused functions over comments that merely restate the code.

We look forward to your contributions!

Metadata

Release files for gerrytools 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gerrytools 2.0.2
File Size Uploaded
gerrytools-2.0.2.tar.gz 522.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for gerrytools 2.0.2
File
gerrytools-2.0.2-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
gerrytools-2.0.2-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details
gerrytools-2.0.2-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details
gerrytools-2.0.2-cp311-abi3-macosx_10_13_x86_64.macosx_11_0_arm64.macosx_10_13_universal2.whl CPython 3.11 abi3 macOS 11.0+ ARM64, macOS 10.13+ universal2 (ARM64, x86-64), macOS 10.13+ x86-64 Details

Total release size: 19.9 MB

Release files / gerrytools-2.0.2.tar.gz

Download URL gerrytools-2.0.2.tar.gz
Size 522.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d620375fcbcf15f2d6d44cb5e26139074fe9ff31e5516815a1f1bc44dacebf1f
BLAKE2b-256 checksum
How to use checksums
82dcb7960d584266a1461ca8fe29d70c5b09afe9370fe449d028881d18623453
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / gerrytools-2.0.2-cp311-abi3-win_amd64.whl

Download URL gerrytools-2.0.2-cp311-abi3-win_amd64.whl
Size 3.7 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
915797558ce8661777ff85eb6f0bf4a0f9d22c32de832607d23322b3656253e2
BLAKE2b-256 checksum
How to use checksums
ff0c8ec8e216649295c822130d1909e5a878bd44fb7b8b72c775f11ae84e1ba2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / gerrytools-2.0.2-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL gerrytools-2.0.2-cp311-abi3-manylinux_2_28_x86_64.whl
Size 4.4 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
bf7f21b8eb44c7fb2f91fcf88e2964bdcfda56c9734258ab35f565bffe00c3f9
BLAKE2b-256 checksum
How to use checksums
6e509714ea53cd9dc4556ea4552fbf0bb0729fa72eb07750e2521d89960a41e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / gerrytools-2.0.2-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL gerrytools-2.0.2-cp311-abi3-manylinux_2_28_aarch64.whl
Size 4.2 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
a7292706d307e87abd7fe1d0abffa67ebc89bd9995e37c69ed705cde125843a7
BLAKE2b-256 checksum
How to use checksums
6413ad9adce0ebc874d6dcc023e991695562ae90930a900f286ce06549885071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / gerrytools-2.0.2-cp311-abi3-macosx_10_13_x86_64.macosx_11_0_arm64.macosx_10_13_universal2.whl

Download URL gerrytools-2.0.2-cp311-abi3-macosx_10_13_x86_64.macosx_11_0_arm64.macosx_10_13_universal2.whl
Size 7.2 MB
Tags CPython 3.11 abi3 macOS 10.13+ universal2 (ARM64, x86-64) macOS 10.13+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b64b2cd16f22784e4906e6556d1012c42b0a7e730efd136bc6856b3905d111a2
BLAKE2b-256 checksum
How to use checksums
ec41a8933274a57f2b43619d5d490f0c638726c0b79002c0fbbdc88ac3211da7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.2 This release

5 release files

2.0.1

5 release files

2.0.0

5 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page