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

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.3
File Size Uploaded Provenance Actions
gerrytools-2.0.3.tar.gz 523.4 kB With provenance Details for gerrytools-2.0.3.tar.gz

Built distributions (wheels)

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

Total release size: 19.9 MB

Release files / gerrytools-2.0.3.tar.gz

Download URL gerrytools-2.0.3.tar.gz
Size 523.4 kB
Tags Source
SHA-256 checksum
How to use checksums
be971600de85988113feb1d60dfe5025b4b5cfac0ff0364e670bed59952898bc
BLAKE2b-256 checksum
How to use checksums
31a419cb1ac77bee0f726606c0cd4c664219b7420bad244057d598ab3669a332
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 Nov 25, 2026.

Transparency log

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

Download URL gerrytools-2.0.3-cp311-abi3-win_amd64.whl
Size 3.7 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1dfaf391d19e56b01b54cf361d676104e5e3b194a1c126ae695ecbbb312b1741
BLAKE2b-256 checksum
How to use checksums
148c1b5ca6f6ea018ca958b19b27f42801cbbb57c3f3996637b5380e9970d202
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 Nov 25, 2026.

Transparency log

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

Download URL gerrytools-2.0.3-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
e62e4d958961ce1ea8356b9f35a59e712f2c87733918b12c5c4d3a7d702abb3f
BLAKE2b-256 checksum
How to use checksums
2773adaf1289378088873404d644e52f0ac8a3cc155cbf71e5e2c96e0685b520
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 Nov 25, 2026.

Transparency log

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

Download URL gerrytools-2.0.3-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
22ccb9e8482dbe293e7894771e129273a4c090e67d6ab29f4e64db97a801f264
BLAKE2b-256 checksum
How to use checksums
e080a8167e6fd749c7e1a545b8f14ce2fc264a97bf68d88b0e44a7c3621f5325
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 Nov 25, 2026.

Transparency log

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

Download URL gerrytools-2.0.3-cp311-abi3-macosx_10_13_universal2.macosx_10_13_x86_64.macosx_11_0_arm64.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
598853b4e0018ff863b710c1b369b5c3bda5b9bf4b503bb2e396704c877424db
BLAKE2b-256 checksum
How to use checksums
9b71d58ce000a456ac207206df095fb79e65fd60349ca82213c0200c9ecfaf6a
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 Nov 25, 2026.

Transparency log

Security for gerrytools 2.0.3

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for gerrytools-2.0.3.tar.gz

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 Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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