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.1

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.1
File Size Uploaded
gerrytools-2.0.1.tar.gz 520.8 kB Details

Built distributions (wheels)

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

Total release size: 20.0 MB

Release files / gerrytools-2.0.1.tar.gz

Download URL gerrytools-2.0.1.tar.gz
Size 520.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f5b4976fca5e94857ebf9f234c98b97dd19116fe5836b96ed68ff7838f8f821f
BLAKE2b-256 checksum
How to use checksums
4f740a6646f2aefb55cea005d1bb05d4f1c6e75976fb9bc58485cfea337721b4
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 Aug 5, 2026.

Transparency log

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

Download URL gerrytools-2.0.1-cp311-abi3-win_amd64.whl
Size 3.7 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
76c59f4a6cdbdc8b907c11a435f7ecc9709ace99b294146a3046620b16094b52
BLAKE2b-256 checksum
How to use checksums
8c10c04ffe93bc2e964ff6b382dca518e05523cd52b08d246705e05797e106a1
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 Aug 5, 2026.

Transparency log

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

Download URL gerrytools-2.0.1-cp311-abi3-manylinux_2_28_x86_64.whl
Size 4.3 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
dc451bfbe2cb7ed0c5a48f9366fd703ab0dd2a10a323e14d41debb1ffac7ec45
BLAKE2b-256 checksum
How to use checksums
2039799a6a239f12dd3861dda637ed9ceeeb83e2bc22a72314300be5b3670a04
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 Aug 5, 2026.

Transparency log

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

Download URL gerrytools-2.0.1-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
d4e1b4e0b71bbf45d9dbae4d051fb2e666999d0ed8d9d4e95d8ecc520cf8b0e4
BLAKE2b-256 checksum
How to use checksums
d7bbc19c22c77b600dd3077fcd8f3eee1b14cce638a4375f2fceabe17d13e9ba
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 Aug 5, 2026.

Transparency log

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

Download URL gerrytools-2.0.1-cp311-abi3-macosx_10_13_x86_64.macosx_11_0_arm64.macosx_10_13_universal2.whl
Size 7.3 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
983ac461ceeb996aa5db9c49a0a031a3843d196bf8bdc5ada008e7c4c78b64f9
BLAKE2b-256 checksum
How to use checksums
94b7d67ef239531fef645b9cff768827498938c1f9b77de68610ca090bb5d77a
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 Aug 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.1 This release

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