Skip to content

Commit 48407fa

Browse files
committed
nicefigs 1.0.0
0 parents  commit 48407fa

227 files changed

Lines changed: 77619 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ci-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
- uses: pre-commit/action@v3.0.1
22+
23+
test:
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
python-version: ["3.10", "3.11", "3.12", "3.13"]
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: astral-sh/setup-uv@v5
32+
- name: Create virtual environment
33+
run: uv venv --python ${{ matrix.python-version }}
34+
- name: Install with dev extras
35+
run: uv pip install -e ".[dev]"
36+
- name: Test
37+
env:
38+
MPLBACKEND: Agg
39+
run: uv run pytest -q
40+
41+
test-minimal:
42+
# Core install only (no cartopy, no xarray): optional-dependency tests must skip, not fail.
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: astral-sh/setup-uv@v5
47+
- name: Create virtual environment
48+
run: uv venv --python 3.12
49+
- name: Install core package only
50+
run: uv pip install -e . pytest
51+
- name: Test
52+
env:
53+
MPLBACKEND: Agg
54+
run: uv run pytest -q
55+
56+
docs:
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: astral-sh/setup-uv@v5
61+
- name: Create virtual environment
62+
run: uv venv --python 3.12
63+
- name: Install with docs extras
64+
run: uv pip install -e ".[docs,maps,xarray]"
65+
- name: Run the code examples of README and docs
66+
env:
67+
MPLBACKEND: Agg
68+
run: uv run python scripts/docs_examples.py
69+
- name: Build site
70+
run: uv run mkdocs build --strict
71+
72+
build:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v4
76+
- uses: astral-sh/setup-uv@v5
77+
- name: Build sdist and wheel
78+
run: uv build
79+
- name: Check distributions
80+
run: uvx twine check --strict dist/*

‎.github/workflows/docs.yml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
concurrency:
12+
group: pages
13+
cancel-in-progress: true
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: astral-sh/setup-uv@v5
21+
- name: Create virtual environment
22+
run: uv venv --python 3.12
23+
- name: Install with docs extras
24+
run: uv pip install -e ".[docs]"
25+
- name: Build site
26+
run: uv run mkdocs build --strict
27+
- name: Deploy to gh-pages
28+
uses: JamesIves/github-pages-deploy-action@v4
29+
with:
30+
folder: site
31+
branch: gh-pages
32+
clean: true
33+
single-commit: true

‎.github/workflows/release.yml‎

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: astral-sh/setup-uv@v5
13+
- name: Check tag matches package version
14+
run: |
15+
version=$(grep -Po '^__version__ = "\K[^"]+' src/nicefigs/__init__.py)
16+
if [ "v${version}" != "${GITHUB_REF_NAME}" ]; then
17+
echo "Tag ${GITHUB_REF_NAME} does not match __version__ ${version}" >&2
18+
exit 1
19+
fi
20+
- name: Build sdist and wheel
21+
run: uv build
22+
- name: Check distributions
23+
run: uvx twine check --strict dist/*
24+
- uses: actions/upload-artifact@v4
25+
with:
26+
name: dist
27+
path: dist/
28+
29+
test-wheel:
30+
needs: build
31+
runs-on: ubuntu-latest
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
python-version: ["3.10", "3.13"]
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: astral-sh/setup-uv@v5
39+
- uses: actions/download-artifact@v4
40+
with:
41+
name: dist
42+
path: dist/
43+
- name: Install the built wheel (not the checkout)
44+
run: |
45+
uv venv --python ${{ matrix.python-version }}
46+
uv pip install "$(ls dist/*.whl)[maps,xarray]" pytest
47+
- name: Test against the installed wheel
48+
env:
49+
MPLBACKEND: Agg
50+
# Moving src/ away guarantees the tests import the installed wheel, not the checkout.
51+
run: |
52+
mv src src.unused
53+
.venv/bin/python -c "import nicefigs; print(nicefigs.__version__, nicefigs.__file__)"
54+
.venv/bin/python -m pytest -q
55+
56+
publish:
57+
needs: test-wheel
58+
runs-on: ubuntu-latest
59+
environment:
60+
name: pypi
61+
url: https://pypi.org/project/nicefigs/
62+
permissions:
63+
id-token: write
64+
steps:
65+
- uses: actions/download-artifact@v4
66+
with:
67+
name: dist
68+
path: dist/
69+
- uses: pypa/gh-action-pypi-publish@release/v1
70+
71+
github-release:
72+
needs: publish
73+
runs-on: ubuntu-latest
74+
permissions:
75+
contents: write
76+
steps:
77+
- uses: actions/checkout@v4
78+
- uses: actions/download-artifact@v4
79+
with:
80+
name: dist
81+
path: dist/
82+
- name: Extract this version's changelog section
83+
run: |
84+
version="${GITHUB_REF_NAME#v}"
85+
awk -v v="$version" '
86+
$0 ~ "^## \\[" v "\\]" {found=1; next}
87+
found && (/^## \[/ || /^\[[^]]+\]: /) {exit}
88+
found {print}
89+
' CHANGELOG.md > release-notes.md
90+
if [ ! -s release-notes.md ]; then
91+
echo "No CHANGELOG.md section for ${version}" >&2
92+
exit 1
93+
fi
94+
- name: Create GitHub release
95+
env:
96+
GH_TOKEN: ${{ github.token }}
97+
run: gh release create "$GITHUB_REF_NAME" dist/* --title "$GITHUB_REF_NAME" --notes-file release-notes.md

‎.gitignore‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.egg-info/
5+
.eggs/
6+
build/
7+
dist/
8+
.venv/
9+
venv/
10+
11+
# Tooling caches
12+
.pytest_cache/
13+
.ruff_cache/
14+
.mypy_cache/
15+
.ipynb_checkpoints/
16+
17+
# Test / build artifacts
18+
tests/baseline_new/
19+
tests/result_images/
20+
# mkdocs build output
21+
site/
22+
scratch_*.py
23+
scratch_*/
24+
25+
# OS
26+
.DS_Store

‎.pre-commit-config.yaml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
exclude: ^docs/(gallery|assets)/
2+
repos:
3+
- repo: https://github.com/astral-sh/ruff-pre-commit
4+
rev: v0.15.0
5+
hooks:
6+
- id: ruff-check
7+
args: [--fix]
8+
- id: ruff-format
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v5.0.0
11+
hooks:
12+
- id: trailing-whitespace
13+
- id: end-of-file-fixer
14+
- id: check-yaml
15+
- id: check-toml
16+
- id: check-added-large-files
17+
args: [--maxkb=1500]

‎CHANGELOG.md‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Changelog
2+
3+
All notable changes to this project are documented here. The format follows
4+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project adheres
5+
to [Semantic Versioning](https://semver.org/).
6+
7+
## [Unreleased]
8+
9+
## [1.0.0] - 2026-11-07
10+
11+
First public release.
12+
13+
### Added
14+
15+
- House style: `set_theme`, the scoped `style` context manager and the `Theme`
16+
presets `paper`, `paper-large`, `talk` and `poster`.
17+
- Physical figure sizing: `figure`, `subplots` and `figure_size` with named
18+
journal and slide widths; `save` to several formats at once;
19+
`check_text_overlaps` to find colliding or clipped text.
20+
- Maps: `map`, `scatter_map`, `binned_map`, `raster_map`, `categorical_map`,
21+
`tri_map`, `hatch_region`, `from_xarray`, with optional cartopy projections
22+
and an inset-histogram colorbar.
23+
- Colour: continuous and categorical palettes (`cmap`, `categorical`,
24+
`qualitative`, `elevation_cmap`, land-cover palettes), a role palette
25+
(`ROLES`, `role_color`, `role_style`), artist palettes, ternary and
26+
bivariate 2D colormaps with legends.
27+
- Plots: `agreement`, `scatter`, `timeseries`, `lines`, `model_comparison`,
28+
`taylor`, `scorecard` and `skill_gap`, `pareto`, `caterpillar`, grouped and
29+
stacked bars, `heatmap`, `image_grid`, `overlay_grid`, `hovmoller`,
30+
`cross_section`, `profile`, `reliability`, `rank_histogram`,
31+
`precision_recall`, `spectrum` (eigenvalue decay or cumulative explained
32+
variance), and the `atlas.component_panel` composite.
33+
- Layout helpers: `panel_label`, `label_panels`, `colorbar`, `facet`,
34+
`row_labels`, `col_labels`, `reference_line`, metric and unit labels.
35+
- Animation: `animate_maps`, `save_animation`, `render_animation`,
36+
`stitch_frames` (MP4 via ffmpeg, GIF fallback).
37+
- Deterministic synthetic example data in `nicefigs.data`.
38+
- One calling convention: plotting helpers take `ax=None` and return `ax` or
39+
`(ax, extra)`; figure helpers return `(fig, axes[, extra])`; decorators take
40+
the axes first. One unit-argument scheme and one "which way is better"
41+
vocabulary, `DIRECTIONS`.
42+
43+
[Unreleased]: https://github.com/EarthyScience/nicefigs/compare/v1.0.0...HEAD
44+
[1.0.0]: https://github.com/EarthyScience/nicefigs/releases/tag/v1.0.0

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Vitus Benson
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎Makefile‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Development tasks, all run through uv.
2+
3+
.PHONY: dev lint test check docs docs-check docs-figures serve-docs gallery logo build
4+
5+
dev:
6+
uv pip install -e ".[dev,docs]"
7+
uv run pre-commit install
8+
9+
lint:
10+
uv run pre-commit run --all-files
11+
12+
test:
13+
MPLBACKEND=Agg uv run pytest
14+
15+
# What CI enforces: pre-commit (ruff lint + format, file hygiene) and the test suite.
16+
check: lint test
17+
18+
docs:
19+
uv run mkdocs build --strict
20+
21+
# Run every README/docs code example and compare it with the output shown.
22+
docs-check:
23+
MPLBACKEND=Agg uv run python scripts/docs_examples.py
24+
25+
# Re-render the guide figures in docs/assets/guide/ from the guide's code examples.
26+
docs-figures:
27+
MPLBACKEND=Agg uv run python scripts/docs_examples.py --render
28+
29+
serve-docs:
30+
uv run mkdocs serve
31+
32+
# Re-render every example into docs/gallery/ and the README images into docs/assets/.
33+
gallery:
34+
MPLBACKEND=Agg uv run python examples/render_gallery.py
35+
36+
# Re-draw the logo files in docs/assets/logo/.
37+
logo:
38+
uv run python scripts/make_logo.py
39+
40+
build:
41+
rm -rf dist
42+
uv run python -m build
43+
uv run twine check --strict dist/*

0 commit comments

Comments
 (0)