figurekit 0.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. figurekit-0.5.1/.gitattributes +7 -0
  2. figurekit-0.5.1/.github/workflows/ci.yml +34 -0
  3. figurekit-0.5.1/.github/workflows/release.yml +89 -0
  4. figurekit-0.5.1/.gitignore +9 -0
  5. figurekit-0.5.1/.pre-commit-config.yaml +30 -0
  6. figurekit-0.5.1/CHANGELOG.md +188 -0
  7. figurekit-0.5.1/LICENSE +21 -0
  8. figurekit-0.5.1/PKG-INFO +439 -0
  9. figurekit-0.5.1/README.md +411 -0
  10. figurekit-0.5.1/docs/examples/bars-dark.png +0 -0
  11. figurekit-0.5.1/docs/examples/bars-dark.svg +1914 -0
  12. figurekit-0.5.1/docs/examples/bars.png +0 -0
  13. figurekit-0.5.1/docs/examples/bars.svg +1914 -0
  14. figurekit-0.5.1/docs/examples/card-dark.png +0 -0
  15. figurekit-0.5.1/docs/examples/card.png +0 -0
  16. figurekit-0.5.1/docs/examples/heatmap-dark.png +0 -0
  17. figurekit-0.5.1/docs/examples/heatmap-dark.svg +1532 -0
  18. figurekit-0.5.1/docs/examples/heatmap.png +0 -0
  19. figurekit-0.5.1/docs/examples/heatmap.svg +1532 -0
  20. figurekit-0.5.1/docs/examples/lines-dark.png +0 -0
  21. figurekit-0.5.1/docs/examples/lines-dark.svg +1773 -0
  22. figurekit-0.5.1/docs/examples/lines.png +0 -0
  23. figurekit-0.5.1/docs/examples/lines.svg +1773 -0
  24. figurekit-0.5.1/docs/examples/multiples-dark.png +0 -0
  25. figurekit-0.5.1/docs/examples/multiples-dark.svg +2215 -0
  26. figurekit-0.5.1/docs/examples/multiples.png +0 -0
  27. figurekit-0.5.1/docs/examples/multiples.svg +2215 -0
  28. figurekit-0.5.1/docs/examples/style/lines-dark.png +0 -0
  29. figurekit-0.5.1/docs/examples/style/lines-dark.svg +1773 -0
  30. figurekit-0.5.1/docs/examples/style/lines-print.png +0 -0
  31. figurekit-0.5.1/docs/examples/style/lines-print.svg +1773 -0
  32. figurekit-0.5.1/docs/examples/style/lines.png +0 -0
  33. figurekit-0.5.1/docs/examples/style/lines.svg +1773 -0
  34. figurekit-0.5.1/docs/examples/style/tokens.json +121 -0
  35. figurekit-0.5.1/docs/readme/before.svg +960 -0
  36. figurekit-0.5.1/docs/readme/modes.png +0 -0
  37. figurekit-0.5.1/docs/style-guide.md +139 -0
  38. figurekit-0.5.1/notes.md +12 -0
  39. figurekit-0.5.1/pyproject.toml +91 -0
  40. figurekit-0.5.1/scripts/build_fonts.py +88 -0
  41. figurekit-0.5.1/scripts/check_package.sh +25 -0
  42. figurekit-0.5.1/scripts/examples.py +223 -0
  43. figurekit-0.5.1/scripts/release_notes.py +56 -0
  44. figurekit-0.5.1/scripts/smoke.py +83 -0
  45. figurekit-0.5.1/src/figkit/__init__.py +141 -0
  46. figurekit-0.5.1/src/figkit/access.py +144 -0
  47. figurekit-0.5.1/src/figkit/check.py +227 -0
  48. figurekit-0.5.1/src/figkit/cli.py +180 -0
  49. figurekit-0.5.1/src/figkit/export.py +366 -0
  50. figurekit-0.5.1/src/figkit/fonts/BricolageGrotesque-Regular.ttf +0 -0
  51. figurekit-0.5.1/src/figkit/fonts/BricolageGrotesque-SemiBold.ttf +0 -0
  52. figurekit-0.5.1/src/figkit/fonts/JetBrainsMono-Regular.ttf +0 -0
  53. figurekit-0.5.1/src/figkit/fonts/JetBrainsMono-SemiBold.ttf +0 -0
  54. figurekit-0.5.1/src/figkit/fonts/OFL-BricolageGrotesque.txt +93 -0
  55. figurekit-0.5.1/src/figkit/fonts/OFL-JetBrainsMono.txt +93 -0
  56. figurekit-0.5.1/src/figkit/helpers.py +404 -0
  57. figurekit-0.5.1/src/figkit/language.py +126 -0
  58. figurekit-0.5.1/src/figkit/manifest.py +188 -0
  59. figurekit-0.5.1/src/figkit/preview.py +103 -0
  60. figurekit-0.5.1/src/figkit/project.py +173 -0
  61. figurekit-0.5.1/src/figkit/py.typed +0 -0
  62. figurekit-0.5.1/src/figkit/theme.py +524 -0
  63. figurekit-0.5.1/src/figkit/tokens.json +52 -0
  64. figurekit-0.5.1/src/figkit/tokens.schema.json +95 -0
  65. figurekit-0.5.1/tests/conftest.py +4 -0
  66. figurekit-0.5.1/tests/test_access.py +84 -0
  67. figurekit-0.5.1/tests/test_figkit.py +477 -0
  68. figurekit-0.5.1/tests/test_language.py +256 -0
  69. figurekit-0.5.1/tests/test_project.py +199 -0
  70. figurekit-0.5.1/tests/test_release.py +85 -0
  71. figurekit-0.5.1/tests/test_style.py +348 -0
  72. figurekit-0.5.1/uv.lock +1020 -0
@@ -0,0 +1,7 @@
1
+ * text=auto eol=lf
2
+ *.png binary
3
+ *.ttf binary
4
+ *.webp binary
5
+ # Generated by matplotlib (path lines end with a space) and verbatim licence texts.
6
+ *.svg -whitespace
7
+ OFL-*.txt -whitespace
@@ -0,0 +1,34 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, develop]
6
+ pull_request:
7
+
8
+ jobs:
9
+ python:
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ # Windows too: the SVGs must be byte-identical on every platform, LF line ends included.
14
+ os: [ubuntu-24.04, windows-2025]
15
+ runs-on: ${{ matrix.os }}
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: astral-sh/setup-uv@v6
19
+ with:
20
+ enable-cache: true
21
+ - run: uv sync --frozen
22
+ # Ruff runs in pre-commit, with the version of uv.lock.
23
+ - run: uv run pre-commit run --all-files --show-diff-on-failure
24
+ - run: uv run mypy
25
+ - run: uv run pytest
26
+ - run: uv run figkit check docs/examples --a11y
27
+ - run: uv run figkit check docs/examples/style --a11y --style docs/examples/style/tokens.json
28
+ # The committed gallery must come out of the script unchanged on this platform.
29
+ - run: uv run python scripts/examples.py
30
+ - run: git diff --exit-code -- "docs/examples/*.svg" "docs/readme/*.svg"
31
+ # The wheel must hold the fonts, tokens and licences that src/ has.
32
+ - run: uv build
33
+ - run: bash scripts/check_package.sh
34
+ shell: bash
@@ -0,0 +1,89 @@
1
+ name: Release
2
+
3
+ # A pushed tag v<version> builds the package, tests the wheel on every platform and publishes the
4
+ # package on PyPI and the GitHub release with the wheel, the source archive and the notes from
5
+ # CHANGELOG.md.
6
+ on:
7
+ push:
8
+ tags: ["v*"]
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-24.04
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: astral-sh/setup-uv@v6
19
+ - name: Tag matches the version in pyproject.toml
20
+ run: |
21
+ version="$(uv version --short)"
22
+ if [ "v$version" != "$GITHUB_REF_NAME" ]; then
23
+ echo "tag $GITHUB_REF_NAME does not match version $version" >&2
24
+ exit 1
25
+ fi
26
+ # Fails before anything is built if the changelog lacks the version.
27
+ - run: uv run --no-project python scripts/release_notes.py "$GITHUB_REF_NAME" > notes.md
28
+ - run: uv build
29
+ - uses: actions/upload-artifact@v4
30
+ with:
31
+ name: release
32
+ path: |
33
+ dist/
34
+ notes.md
35
+ if-no-files-found: error
36
+
37
+ wheel:
38
+ needs: build
39
+ strategy:
40
+ fail-fast: false
41
+ matrix:
42
+ os: [ubuntu-24.04, windows-2025]
43
+ runs-on: ${{ matrix.os }}
44
+ steps:
45
+ - uses: actions/checkout@v4
46
+ - uses: astral-sh/setup-uv@v6
47
+ - uses: actions/download-artifact@v4
48
+ with:
49
+ name: release
50
+ - run: bash scripts/check_package.sh
51
+ shell: bash
52
+
53
+ # Trusted publishing: PyPI accepts the upload from this workflow in the environment pypi, so
54
+ # the repository holds no token. A version that PyPI already has fails here, before GitHub.
55
+ pypi:
56
+ needs: wheel
57
+ runs-on: ubuntu-24.04
58
+ environment:
59
+ name: pypi
60
+ url: https://pypi.org/project/figurekit/
61
+ permissions:
62
+ id-token: write
63
+ steps:
64
+ - uses: actions/download-artifact@v4
65
+ with:
66
+ name: release
67
+ - uses: pypa/gh-action-pypi-publish@release/v1
68
+
69
+ publish:
70
+ needs: pypi
71
+ runs-on: ubuntu-24.04
72
+ permissions:
73
+ contents: write
74
+ steps:
75
+ - uses: actions/download-artifact@v4
76
+ with:
77
+ name: release
78
+ # A release made by hand keeps its notes and gets the files.
79
+ - name: Publish the release
80
+ env:
81
+ GH_TOKEN: ${{ github.token }}
82
+ GH_REPO: ${{ github.repository }}
83
+ run: |
84
+ if gh release view "$GITHUB_REF_NAME" > /dev/null 2>&1; then
85
+ gh release upload "$GITHUB_REF_NAME" dist/* --clobber
86
+ else
87
+ gh release create "$GITHUB_REF_NAME" dist/* --verify-tag \
88
+ --title "$GITHUB_REF_NAME" --notes-file notes.md
89
+ fi
@@ -0,0 +1,9 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.egg-info/
4
+ .mypy_cache/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ build/
8
+ dist/
9
+ .vscode/
@@ -0,0 +1,30 @@
1
+ # Install once with `uv run pre-commit install`. CI runs every hook on all files.
2
+ repos:
3
+ - repo: https://github.com/pre-commit/pre-commit-hooks
4
+ rev: v6.0.0
5
+ hooks:
6
+ - id: check-yaml
7
+ - id: check-toml
8
+ - id: check-json
9
+ - id: end-of-file-fixer
10
+ exclude: \.svg$
11
+ - id: trailing-whitespace
12
+ # matplotlib ends SVG path lines with a space, and licence texts stay verbatim.
13
+ exclude: (\.svg|OFL-.*\.txt)$
14
+ - id: check-added-large-files
15
+ args: [--maxkb=512]
16
+ # Ruff from uv.lock, so pre-commit, CI and the editor use the same version.
17
+ - repo: local
18
+ hooks:
19
+ - id: ruff-check
20
+ name: ruff check
21
+ entry: uv run --frozen ruff check --fix
22
+ language: system
23
+ types_or: [python, pyi]
24
+ require_serial: true
25
+ - id: ruff-format
26
+ name: ruff format
27
+ entry: uv run --frozen ruff format
28
+ language: system
29
+ types_or: [python, pyi]
30
+ require_serial: true
@@ -0,0 +1,188 @@
1
+ # Changelog
2
+
3
+ Every release of figkit, newest first. Versions follow [Semantic Versioning](https://semver.org);
4
+ before 1.0 a minor version may break the API. The GitHub release of a tag takes its notes from the
5
+ section of that version.
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.5.1] - 2026-11-27
10
+
11
+ ### Changed
12
+
13
+ - The package is published on PyPI as `figurekit`, since `figkit` belongs to another project
14
+ there. Install it with `uv add figurekit`; the module and the command stay `figkit`. A project
15
+ that installed the Git tag replaces `figkit @ git+...` with `figurekit` in its dependencies.
16
+ - The release workflow uploads the wheel and the source archive to PyPI with trusted publishing.
17
+
18
+ ## [0.5.0] - 2026-11-26
19
+
20
+ ### Added
21
+
22
+ - `figkit init` copies the bundled tokens and their schema into a project and appends
23
+ `[tool.figkit]` to its `pyproject.toml`. An existing tokens file is kept and checked; an
24
+ existing table stops the command.
25
+ - `figkit style preview` renders a specimen of every series, ramp and status colour in each
26
+ theme of the project style or of `--style`.
27
+ - Chart helpers: `band` shades an interval such as a confidence band in the colour of its
28
+ series, `error_bars` draws thin bars without caps, `callout` points at a value with an arrow,
29
+ `small_multiples` lays out panels on the canvas width with shared axes and `ramp_cmap` turns
30
+ the ramp of a theme into a colormap.
31
+ - The gallery shows small multiples with bands and a callout.
32
+ - `figkit check --a11y` checks the colours of the style: text contrast after WCAG, the
33
+ separation of neighbouring series with protanopia, deuteranopia and normal vision, and the
34
+ steps of the ramp. It runs without a directory as well.
35
+
36
+ ### Changed
37
+
38
+ - The dark ramp of the bundled style is stepped evenly in lightness. Three middle steps were
39
+ less than 0.06 apart; dark heatmaps and the tiles of the dark card change their blues.
40
+ - The example style in `docs/examples/style` orders its series teal, blue, amber, magenta, so
41
+ that neighbours stay apart with deuteranopia.
42
+
43
+ ## [0.4.0] - 2026-11-26
44
+
45
+ ### Added
46
+
47
+ - A style of your own. `load_style` reads a tokens file in the new version 2 with any number of
48
+ themes, a `default` theme whose files carry no suffix, theme `pair`s, project font files in
49
+ `font.files` and a `css` mapping for the stylesheet check. `StyleError` lists every problem of
50
+ the file with its place and catches unknown keys; `tokens.schema.json` helps editors.
51
+ - `render`, `page`, `page_entry`, `path_for`, `check`, `check_tokens` and `ink_on` take an
52
+ optional `style`. `figkit check` pairs only themes that name a pair, and the manifest lists the
53
+ files under the names of all themes.
54
+ - Each `Theme` carries its fonts and sizes as `Typography` in `theme.type`; the helpers, `rc` and
55
+ the minimum text size take them from the theme they draw with.
56
+ - `[tool.figkit]` in `pyproject.toml` names `tokens` and `css` of a project. `figkit.project()`
57
+ and `figkit.project_style()` read it, and `figkit check` uses it unless `--style` or `--css`
58
+ override it.
59
+
60
+ ### Changed
61
+
62
+ - `figkit check --tokens` is now `--css`; `--tokens` stays as an alias.
63
+ - The bundled `tokens.json` uses version 2. Files without `version` still load as version 1 and
64
+ give the same style. A version 2 file without `css` names no properties for `check --css`.
65
+ - `mono()` and `mono_ticks()` accept a theme and use its mono family.
66
+
67
+ ### Fixed
68
+
69
+ - A tokens file of version 1 defaults to `light` even when `dark` comes first in it.
70
+ - A `css` index beyond a list token and an absolute pattern in `font.files` are a `StyleError`
71
+ instead of a crash in `check_tokens` or `load_style`.
72
+ - `figkit check --css` reports a stylesheet it cannot read instead of failing with a traceback.
73
+
74
+ ## [0.3.1] - 2026-11-19
75
+
76
+ ### Added
77
+
78
+ - Each release attaches the wheel and the source archive. CI builds both and checks that the
79
+ installed wheel renders figures with the bundled fonts.
80
+
81
+ ### Fixed
82
+
83
+ - `register_fonts` accepts the bundled fonts when Windows gives the package a short 8.3 path,
84
+ such as a virtual environment under `C:\Users\RUNNER~1\...`. Before, every figure failed with
85
+ "not to the bundled file".
86
+
87
+ ## [0.3.0] - 2026-11-19
88
+
89
+ ### Breaking changes
90
+
91
+ - Importing figkit leaves the matplotlib backend alone. It no longer switches to `Agg`, so
92
+ `plt.show()` and notebooks keep their backend. A batch job that only writes files can set
93
+ `MPLBACKEND=Agg`.
94
+ - A theme other than `light` and `dark` writes `<name>[.<language>]-<theme>.<format>` instead of
95
+ overwriting the light files.
96
+ - German figures can change on the next render: bar values, numbers at the end of a sentence and
97
+ category names with numbers are written differently, see below.
98
+
99
+ ### Fixed
100
+
101
+ - `localize` converts a number followed by a full stop: `F1 is 0.95.` becomes `F1 is 0,95.`.
102
+ Versions such as `v0.1.2` stay as they are.
103
+ - `bar_labels` writes the values it formats in the language of the figure, `0,93` in German.
104
+ Texts passed as `labels` stay as given.
105
+ - German tick labels leave category names unchanged when the categories are plotted as strings,
106
+ such as `ax.bar(["1.5 mm", ...])`.
107
+ - SVGs with embedded images, such as heatmaps drawn with `imshow`, are byte-identical on Linux and
108
+ Windows. Before, Pillow builds compressed the same pixels to different bytes.
109
+ - `Theme` is hashable and its `status` colours are read-only.
110
+ - `figkit check` reports a malformed `figures.json` (invalid JSON, wrong types, missing files)
111
+ instead of failing with a traceback.
112
+ - `figkit check --opaque card` also covers the language files `card.de.png` and `card.en.png`.
113
+ - `page_entry` reads the size of raster files from the dpi or pixel width of their output instead
114
+ of assuming 250 dpi.
115
+
116
+ ### CI
117
+
118
+ - Tests run on Ubuntu and Windows. CI regenerates the example gallery and fails if an SVG changes.
119
+ - pre-commit runs ruff from `uv.lock`, so the hook and CI use the same version.
120
+
121
+ ## [0.2.1] - 2026-11-10
122
+
123
+ ### Added
124
+
125
+ - `page_entry` reads the manifest entry of a figure from files that a separate step wrote, such
126
+ as a figure that needs a trained model. One step can still write the manifest of all figures.
127
+
128
+ ## [0.2.0] - 2026-11-10
129
+
130
+ ### Added
131
+
132
+ - `render` takes a `language` and a `headless` flag. German tick labels and `figkit.number` use a
133
+ decimal comma, a thousands dot and a spaced percent sign.
134
+ - `page` writes a figure without its title in every language, and `write_manifest` lists the
135
+ files with their titles and alt texts in `figures.json`.
136
+ - `figkit check` reports missing languages, gaps in the manifest and, with `--tokens`, page
137
+ colours that differ from the website's stylesheet.
138
+
139
+ ### Changed
140
+
141
+ - `render` rejects text below 8 pt, because pages scale the canvas down on phones.
142
+
143
+ ## [0.1.2] - 2026-11-10
144
+
145
+ ### Added
146
+
147
+ - Web figures are exactly 6.4 in wide, the PNG 1600 px, so text has the same size in every
148
+ figure.
149
+ - `figkit check` fails on figures off the canvas width; `--any-width` skips the check.
150
+ - `line_labels` places direct labels at the ends of lines.
151
+
152
+ ### Fixed
153
+
154
+ - `render` names the figure that does not fit the canvas.
155
+ - SVG files have LF line ends on every platform.
156
+ - Every mathtext face points to the bundled fonts, so Linux finds no missing family.
157
+ - The PNG budget of photographs is 1 MB, enough for full-width grids on the fixed canvas.
158
+
159
+ ## [0.1.1] - 2026-11-10
160
+
161
+ ### Fixed
162
+
163
+ - Palette PNGs keep the tones of photographs. Photo PNGs may be larger.
164
+ - Bold mathtext uses the bundled semibold.
165
+
166
+ ## [0.1.0] - 2026-11-10
167
+
168
+ ### Added
169
+
170
+ - Light and dark themes from the portfolio tokens, with bundled Bricolage Grotesque and
171
+ JetBrains Mono.
172
+ - Transparent SVG and PNG export with byte-identical SVGs, plus WebP for photographs and an
173
+ opaque Open Graph card.
174
+ - Helpers for titles, legends, grids, percent axes, values, bar labels and reference lines; the
175
+ label of a vertical reference line goes on either side.
176
+ - `figkit check` for light/dark pairs, transparency and file sizes.
177
+
178
+ [Unreleased]: https://github.com/BenBotsch/FigureKit/compare/v0.5.1...HEAD
179
+ [0.5.1]: https://github.com/BenBotsch/FigureKit/compare/v0.5.0...v0.5.1
180
+ [0.5.0]: https://github.com/BenBotsch/FigureKit/compare/v0.4.0...v0.5.0
181
+ [0.4.0]: https://github.com/BenBotsch/FigureKit/compare/v0.3.1...v0.4.0
182
+ [0.3.1]: https://github.com/BenBotsch/FigureKit/compare/v0.3.0...v0.3.1
183
+ [0.3.0]: https://github.com/BenBotsch/FigureKit/compare/v0.2.1...v0.3.0
184
+ [0.2.1]: https://github.com/BenBotsch/FigureKit/compare/v0.2.0...v0.2.1
185
+ [0.2.0]: https://github.com/BenBotsch/FigureKit/compare/v0.1.2...v0.2.0
186
+ [0.1.2]: https://github.com/BenBotsch/FigureKit/compare/v0.1.1...v0.1.2
187
+ [0.1.1]: https://github.com/BenBotsch/FigureKit/compare/v0.1.0...v0.1.1
188
+ [0.1.0]: https://github.com/BenBotsch/FigureKit/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Benny Botsch
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.