Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8a46898
First commit for RustworkX conversion project.
May 6, 2025
1da756d
Added logic to support RX as the Graph provider after creating
May 23, 2025
fed50b3
Added laplacian_matrix() and normalized_laplacian_matrix() methods to…
Jul 8, 2025
4f3de78
More changes to get tests to pass
Jul 16, 2025
b516b00
Deleted files from the repo that should not be tracked...
Jul 17, 2025
3346b8a
Lots and lots of changes to get tests to run.
Jul 27, 2025
c98c591
Yet more changes to get tests to pass...
Jul 29, 2025
3c16cfe
Mostly cosmetic changes to change Camel-Case to Snake-Case such
Jul 30, 2025
485ac86
Yet more changes to get tests to pass.
Aug 2, 2025
30d0731
Removed debugging code (print stmts)
Aug 4, 2025
357b3a7
Yet more changes to get tests to pass.
Aug 16, 2025
eaab345
Added test for conversion from NX graph back to NX graph after runnin…
Aug 16, 2025
59814c5
Since returning from vacation, I have been focused on getting all of
Oct 12, 2025
295ae3b
Performance Changes:
Oct 28, 2025
96a1ced
CLEAN-UP work: no new functionality
Nov 5, 2025
848ce6d
Added a test file and a README.txt file for tests.
Nov 5, 2025
c1c8d3f
Trivial changes - I just categorized all of the TODO: comments
Nov 6, 2025
3f04b27
Mostly a "cleanup" set of changes - code readability,
Dec 8, 2025
0e56800
Added two performance tests - using cProfile
Dec 8, 2025
3c55e03
Trivial one-line change in a comment...
Dec 8, 2025
1ceb7ed
Update build tools
peterrrock2 Dec 11, 2025
be292df
Update formatters and run
peterrrock2 Dec 11, 2025
41e6584
Update pyproject.toml
peterrrock2 Dec 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions .github/workflows/docs-pr-check.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
name: "Pull Request Docs Check"
on:
- pull_request

on:
pull_request:

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ammaraskar/sphinx-action@master
with:
docs-folder: "docs/"
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Set up uv
uses: astral-sh/setup-uv@v4

- name: Build docs
run: make docs
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ __pycache__/
# C extensions
*.so

# dev stuff
dev_files

# Distribution / packaging
.Python
env/
Expand Down Expand Up @@ -83,4 +86,4 @@ TODO.md

# Environment items
.env
.envrc
.envrc
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
files: gerrytools/
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

96 changes: 96 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Makefile for managing GerryChain development tasks using 'uv' virtual environment manager.

PYTHON_VERSION = 3.11
VENV_DIR ?= .venv
PKG ?= gerrychain
TEST_PATHS ?= tests

.PHONY: help setup install dev install-docs test lint format precommit docs clean

help:
@echo "Available targets:"
@echo " setup - Set up environment for full development including dev dependencies and pre-commit hooks"
@echo " install - Install the package"
@echo " install-docs - Install documentation dependencies"
@echo " test - Run the test suite"
@echo " lint - Run code linters"
@echo " format - Format the codebase"
@echo " precommit - Run pre-commit hooks"
@echo " docs - Build the documentation"
@echo " clean - Clean build artifacts"


check_prereq:
@echo "Checking prerequisites..."
@if ! command -v uv > /dev/null 2>&1; then \
echo "Error: 'uv' is not installed. Please install it first using the following command:"; \
echo " curl -LsSf https://astral.sh/uv/install.sh | sh"; \
exit 1; \
fi
@echo "'uv' is installed."

setup: check_prereq
@echo "Setting up the development environment for GerryChain..."
@echo
uv python install $(PYTHON_VERSION)
@echo "Creating virtual environment and installing dev dependencies..."
uv sync --python $(PYTHON_VERSION)
uv sync --all-groups
uv pip install -e .
uv run pre-commit install
@echo ""
@echo "Development environment setup complete!"

install: check_prereq
@echo "Installing GerryChain package..."
uv sync --python $(PYTHON_VERSION)
uv pip install -e .

install-docs: check_prereq
@echo "Installing GerryChain package with all just the documentation dependencies..."
uv sync --python $(PYTHON_VERSION)
uv sync --group docs
uv pip install -e .

test:
@echo "Running test suite..."
uv run pytest -v $(TEST_PATHS)

# Add this in later
# type-check:
# @echo "Running type checking with mypy..."
# uv run mypy $(PKG) ${TEST_PATHS}

format:
@echo "Formatting codebase with black..."
uv run isort $(PKG) $(TEST_PATHS)
uv run black $(PKG) $(TEST_PATHS)

lint:
@echo "Running linters (ruff)..."
uv run ruff check $(PKG) $(TEST_PATHS)

precommit:
@echo "Running pre-commit hooks..."
uv run pre-commit install
uv run pre-commit run --all-files

docs: install-docs
@echo "Building documentation..."
uv run sphinx-build -b html docs/ docs/_build

clean:
@echo "Cleaning build artifacts..."
@rm -rf build/ \
dist/ \
*.egg-info \
.pytest_cache/ \
.mypy_cache/ \
.ruff_cache/ \
docs/_build/ \
$(VENV_DIR) \
.vscode/ \
.ipynb_checkpoints/ \
docs/build/
@find . -type d -name "__pycache__" -exec rm -rf {} +
@echo "Clean complete."
20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

31 changes: 2 additions & 29 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -120,7 +120,7 @@
#
# html_sidebars = {}
html_css_files = [
'css/custom.css',
"css/custom.css",
]


Expand Down Expand Up @@ -192,33 +192,6 @@

autodoc_default_flags = ["members"]

# -- Mock C libraries --------------------------------------------------------

# RTD is unable to install libraries with C dependencies.
# We're using the mock module to mock those away.

MOCK_MODULES = [
"numpy",
"pandas",
"geopandas",
"matplotlib",
"matplotlib.pyplot",
# "networkx",
# "networkx.readwrite",
# "networkx.algorithms",
# "networkx.algorithms.shortest_paths",
# "networkx.algorithms.shortest_paths.weighted",
"shapely",
"shapely.ops",
"shapely.strtree",
"shapely.prep",
"shapely.prepared",
"shapely.validation",
"gerrychain.vendor.utm",
]

for module in MOCK_MODULES:
sys.modules[module] = mock.Mock()

# -- Extension configuration -------------------------------------------------

Expand Down
4 changes: 0 additions & 4 deletions docs/geo_settings.txt

This file was deleted.

8 changes: 6 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ repository, where `bug reports and feature requests`_, as well as
.. _`contributions`: https://github.com/mggg/gerrychain/pulls


.. include:: user/install.rst
.. include:: user/install_header.rst

For more detailed installation instructions, including instructions for
setting up virtual environments, please see the following section:
:doc:`user/install`.

.. toctree::
:caption: User Guide
Expand Down Expand Up @@ -82,4 +86,4 @@ MGGG for the 2019 MIT IAP course `Computational Approaches for Political Redistr
:caption: Index
:maxdepth: 4

full_ref
full_ref
36 changes: 0 additions & 36 deletions docs/make.bat

This file was deleted.

8 changes: 0 additions & 8 deletions docs/requirements.txt

This file was deleted.

33 changes: 1 addition & 32 deletions docs/user/install.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
Installation
============

Supported Python Versions
-------------------------

The most recent version of GerryChain (as of April 2024) supports

- Python 3.9
- Python 3.10
- Python 3.11
- Python 3.12

If you do not have one of these versions installed on you machine, we
recommend that you go to the
`Python website <https://www.python.org/downloads/>`_ and
download the installer for one of these versions. [1]_
.. include:: ./install_header.rst

.. admonition:: A Note For Windows Users
:class: note
Expand Down Expand Up @@ -130,17 +114,6 @@ ready to install GerryChain.
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``. If you run into this issue, try installing
the dependencies using the
`geo_settings.txt <https://github.com/mggg/GerryChain/tree/main/docs/geo_settings.txt>`_
file. To do this, run ``pip install -r geo_settings.txt`` from the
command line.

.. note::

Expand All @@ -151,10 +124,6 @@ command line.
line.

.. _PyPI: https://pypi.org/
.. [1] Of course, if you are using a Linux system, you will either need to use your
system's package manager or install from source. You may also find luck installing
Python directly from the package manager if you find installing from source to be
troublesome.


.. include:: ../repeated_subsections/reproducible_envs.rst
23 changes: 23 additions & 0 deletions docs/user/install_header.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Installation
============

Supported Python Versions
-------------------------

The most recent version of GerryChain (as of April 2024) supports

- Python 3.11
- Python 3.12
- Python 3.13

If you do not have one of these versions installed on you machine, we
recommend that you go to the
`Python website <https://www.python.org/downloads/>`_ and
download the installer for one of these versions.

Most users can install GerryChain using pip:

.. code:: console

pip install gerrychain

Loading