Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
88 changes: 62 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,98 @@ jobs:
python-version: ["3.10", "3.11"]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install uv and Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
version: "0.11.32"
enable-cache: true

- name: Install dependencies
run: poetry install --without compass
run: uv sync --locked

- name: Run tests
run: poetry run pytest
run: uv run pytest

lint:
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv and Python
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: "3.11"
version: "0.11.32"
enable-cache: true

- name: Install ruff
run: pip install ruff
- name: Install dependencies
run: uv sync --locked

- name: Run ruff
run: ruff check pleque/ tests/
run: uv run ruff check pleque/ tests/

typecheck:
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv and Python
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: "3.11"

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
version: "0.11.32"
enable-cache: true

- name: Install dependencies
run: poetry install --without compass
run: uv sync --locked

- name: Run ty
run: poetry run ty check pleque/
run: uv run ty check pleque/
continue-on-error: true # ty is new; don't fail CI until annotations are complete

build:
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v7

- name: Install uv and Python
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: "3.11"
version: "0.11.32"
enable-cache: true

- name: Build distributions
run: uv build

docs:
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v7

- name: Install uv and Python
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: "3.11"
version: "0.11.32"
enable-cache: true

- name: Install dependencies
run: uv sync --locked

- name: Install Pandoc
run: sudo apt-get update && sudo apt-get install --yes --no-install-recommends pandoc

- name: Build documentation
run: uv run make -C docs html
27 changes: 10 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Tests

on:
push:
branches: [master, main]
branches: [master, main, develop]
pull_request:
branches: [master, main]
branches: [master, main, develop]

jobs:
test:
Expand All @@ -15,31 +15,24 @@ jobs:
pull-requests: write

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

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

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Cache Poetry dependencies
uses: actions/cache@v4
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
version: "0.11.32"
enable-cache: true

- name: Install dependencies
run: poetry install --without compass
run: uv sync --locked

- name: Run tests
run: poetry run pytest --junitxml=report.xml --cov=pleque --cov-report=xml:coverage.xml --cov-report=term-missing
run: uv run pytest --junitxml=report.xml --cov=pleque --cov-report=xml:coverage.xml --cov-report=term-missing

- name: Upload test results artifact
uses: actions/upload-artifact@v4
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ docs/_static/
docs/source/_build/

venv/
.venv/
.uv-cache/
/local/gfile_vs_spline.ipynb
/local/
45 changes: 23 additions & 22 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
#image: python:3.9
image: python:3.10

variables:
POETRY_HOME: "$CI_PROJECT_DIR/.poetry"
POETRY_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pypoetry"
UV_CACHE_DIR: "/tmp/.uv-cache"
UV_LINK_MODE: copy

cache:
paths:
- .poetry
- .cache/pypoetry

before_script:
- curl -sSL https://install.python-poetry.org | python3 -
- export PATH="$POETRY_HOME/bin:$PATH"
- poetry config virtualenvs.create false
- poetry install --without compass # --with omas # omas is temporarily skipped due to the complicated dependencies
default:
before_script:
- python -m pip install --disable-pip-version-check "uv==0.11.32"
- uv sync --locked

test:pytest:
script:
- pytest --junitxml=report.xml --cov=pleque --cov-report=xml:coverage.xml --cov-report=term-missing
- uv run pytest --junitxml=report.xml --cov=pleque --cov-report=xml:coverage.xml --cov-report=term-missing
artifacts:
when: always
reports:
Expand All @@ -30,19 +23,27 @@ test:pytest:
- report.xml
- coverage.xml
expire_in: 1 week
- pytest

lint:ruff:
stage: test
script:
- pip install ruff
- ruff check pleque/ tests/
- uv run ruff check pleque/ tests/
needs: ["test:pytest"]

typecheck:ty:
stage: test
script:
- pip install ty
- ty check pleque/
- uv run ty check pleque/
needs: ["test:pytest"]
allow_failure: true # ty is new; don't block pipeline until annotations are complete
allow_failure: true

build:package:
script:
- uv build

docs:html:
before_script:
# nbsphinx converts the example notebooks with pandoc
- apt-get update
- apt-get install --yes --no-install-recommends pandoc
- !reference [default, before_script]
script:
- uv run make -C docs html
28 changes: 28 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Repository Guidelines

## Project Structure & Module Organization

`pleque/` contains the installable Python package. Core equilibrium and coordinate behavior lives in `pleque/core/`; format readers and writers are in `pleque/io/`; shared numerical and plotting helpers are in `pleque/utils/`; spatial transformations are in `pleque/spatran/`. Keep bundled sample equilibria in `pleque/resources/`. The main test suite is under `tests/`, with reusable package-side test helpers in `pleque/tests/`. User-facing demonstrations belong in `examples/` or `notebooks/`, while Sphinx sources live in `docs/source/`.

## Build, Test, and Development Commands

- `uv sync` creates the locked development environment from `pyproject.toml` and `uv.lock`.
- `uv sync --group compass` additionally installs the optional COMPASS/CDB integration.
- `uv run pytest` runs the complete test suite configured by `pytest.ini`.
- `uv run pytest tests/test_gfile.py -q` runs a focused module while developing.
- `uv run ruff check pleque tests` checks Python style and common correctness issues.
- `uv run ty check pleque` runs the advisory type checker used by CI.
- `uv build` creates source and wheel distributions through Hatchling.
- `uv run make -C docs html` builds the Sphinx documentation into `docs/build/html/`.

## Coding Style & Naming Conventions

Use four-space indentation and follow the existing scientific Python style. Name modules, functions, and variables with `snake_case`; classes use `PascalCase`; constants use `UPPER_SNAKE_CASE`. Preserve established domain notation such as `R`, `Z`, `psi_n`, and `COCOS` where it improves correspondence with equations and file formats. Keep public APIs documented with concise docstrings, and avoid mixing unrelated formatting changes into functional patches. Use Ruff for linting and `uv run ruff format pleque tests` for automatic formatting.

## Testing Guidelines

Tests use Pytest and NumPy assertion helpers. Add tests close to the affected behavior, normally as `tests/test_<topic>.py` with functions named `test_<behavior>`. Reuse fixtures from `tests/conftest.py` and sample data from `pleque/resources/` instead of adding large generated artifacts. Cover numerical results with explicit tolerances and include regression cases for bug fixes. Run focused tests first, then the full suite before submitting.

## Commit & Pull Request Guidelines

Recent history favors short, imperative or descriptive subjects such as `Add reference publication to README.md` and `Update dependencies`. Keep each commit scoped to one logical change; use `Bump version to X.Y.Z` for release-only version commits. Pull requests should explain the user-visible or numerical impact, list verification commands, and link relevant issues. Include plots or screenshots when visualization output changes, and call out compatibility, dependency, or equilibrium-data changes explicitly.
24 changes: 13 additions & 11 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Shared contributor instructions are defined in `AGENTS.md`; this file adds Claude-specific project context.

## Overview

Expand All @@ -10,27 +11,28 @@ typically constructed by reading an equilibrium file (e.g. G-EQDSK) via `pleque.

## Commands

The project uses Poetry. The `compass` dependency group pulls `pycdb-compass` from an internal
IPP git repository that is not reachable outside the COMPASS network — always exclude it:
The project uses uv. The `compass` dependency group pulls `pycdb-compass` from an internal
IPP git repository that is not reachable outside the COMPASS network, so install it only when needed:

```bash
poetry install --without compass # install dependencies (this is what CI does)
uv sync # install locked default and development dependencies
uv sync --group compass # additionally install the COMPASS integration

poetry run pytest # run the whole test suite
poetry run pytest tests/test_equilibria.py # run one test file
poetry run pytest tests/test_equilibria.py::test_name # run a single test
uv run pytest # run the whole test suite
uv run pytest tests/test_equilibria.py # run one test file
uv run pytest tests/test_equilibria.py::test_name # run a single test

ruff check pleque/ tests/ # lint (CI runs exactly this)
ruff format pleque/ tests/ # format (line-length 120, double quotes)
uv run ruff check pleque/ tests/ # lint (CI runs exactly this)
uv run ruff format pleque/ tests/ # format (line-length 120, double quotes)

poetry run ty check pleque/ # type check (advisory: CI runs it with continue-on-error
# because the legacy codebase is largely un-annotated)
uv run ty check pleque/ # type check (advisory: CI runs it with continue-on-error
# because the legacy codebase is largely un-annotated)
```

Tests that need unavailable optional dependencies (e.g. `pyCDB` in `tests/test_cdb.py`) skip
themselves via `pytest.importorskip` — they are not failures.

Docs are Sphinx-based in `docs/` (built on Read the Docs): `make -C docs html`.
Docs are Sphinx-based in `docs/` (built on Read the Docs): `uv run make -C docs html`.

## Branches and releases

Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ pip install --user .
```
Congratulations, you have just installed `pleque`!

### Development with uv

For a development checkout, install the locked runtime and development
dependencies with [uv](https://docs.astral.sh/uv/):

```bash
uv sync
```

Run tests through the managed environment:

```bash
uv run pytest
```

The optional COMPASS integration can be installed with:

```bash
uv sync --group compass
```

## Examples

The following example shows how to load an equilibrium saved in the `eqdsk` format. The equilibrium used here comes from a FIESTA simulation of the COMPASS-Upgrade tokamak.
Expand Down
4 changes: 3 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#

# You can set these variables from the command line.
SPHINXOPTS =
# -W turns Sphinx warnings into errors so the build stays warning-free;
# override with e.g. `make html SPHINXOPTS=` while iterating on the docs.
SPHINXOPTS = -W
SPHINXBUILD = python -msphinx
SPHINXPROJ = Pleque
SOURCEDIR = source
Expand Down
8 changes: 5 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,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 = None
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 @@ -164,8 +164,10 @@
'Miscellaneous'),
]

#Give each notebook cell 3 minutes to execute
nbsphinx_timeout=180
# Render committed notebook outputs during documentation builds. Executing the
# example notebooks is a separate maintenance task and is not reproducible in
# the minimal documentation environment.
nbsphinx_execute = 'never'


def skip(app, what, name, obj, would_skip, options):
Expand Down
Loading
Loading