Skip to content

Commit f9c37bf

Browse files
committed
Add dynamic docs versioning, VQC sensitivity experiment, and minor fixes
Docs versioning: - Add MkDocs on_config hook that reads the package version from setuptools-scm (_version.py or installed package) and injects it into the template context, replacing the hardcoded v0.1 badge. - Strip dev/local suffixes so the docs always display the last tagged release (e.g. 0.3.1.dev1+g... -> 0.3.0). - Add fetch-depth: 0 to CI docs job for correct version resolution. VQC sensitivity experiment (Stage 6a.5): - Grid search over learning rates and variational layers for angle and IQP encodings on moons/circles datasets. - Checkpoint-based crash-safe resume, deterministic seed strategy, and JSON report with per-cell statistics and analysis summary. - Comprehensive mocked test suite (tests/unit/experiments/). Minor: - Add paper/ to .gitignore. - Switch PyPI badge to shields.io in README. - Batch instantiation timings in test_performance for stability.
1 parent c4e3886 commit f9c37bf

10 files changed

Lines changed: 2681 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ jobs:
150150
steps:
151151
- name: Checkout code
152152
uses: actions/checkout@v4
153+
with:
154+
fetch-depth: 0
153155

154156
- name: Set up Python
155157
uses: actions/setup-python@v5

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ experiments/plotting_journal.py
7171
# Verification folder (temporary)
7272
verification/
7373

74+
# Paper (private drafts)
75+
paper/
76+
7477
# OS
7578
.DS_Store
7679
Thumbs.db

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
**The comprehensive library for quantum data encodings in machine learning**
66

7-
[![PyPI version](https://badge.fury.io/py/encoding-atlas.svg)](https://pypi.org/project/encoding-atlas/)
7+
[![PyPI version](https://img.shields.io/pypi/v/encoding-atlas.svg)](https://pypi.org/project/encoding-atlas/)
88
[![Python versions](https://img.shields.io/pypi/pyversions/encoding-atlas.svg)](https://pypi.org/project/encoding-atlas/)
99
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
1010
[![CI](https://img.shields.io/github/actions/workflow/status/encoding-atlas/quantum-encoding-atlas/ci.yml?branch=master&logo=github&label=CI)](https://github.com/encoding-atlas/quantum-encoding-atlas/actions/workflows/ci.yml)

docs/hooks/version_hook.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""MkDocs hook to inject the package version into template context."""
2+
3+
from __future__ import annotations
4+
5+
import re
6+
from pathlib import Path
7+
8+
9+
def _strip_dev_suffix(version: str) -> str:
10+
"""Strip setuptools-scm dev/local suffixes to show the last release version.
11+
12+
Examples: '0.3.1.dev1+gbd09888de' -> '0.3.0', '0.3.0' -> '0.3.0'
13+
"""
14+
match = re.match(r"(\d+\.\d+\.\d+)", version)
15+
if match:
16+
base = match.group(1)
17+
# If this is a dev version (e.g. 0.3.1.dev1), the base patch was
18+
# bumped by setuptools-scm; roll it back to the actual tagged release.
19+
if ".dev" in version:
20+
major, minor, patch = base.split(".")
21+
patch = str(max(int(patch) - 1, 0))
22+
return f"{major}.{minor}.{patch}"
23+
return base
24+
return version
25+
26+
27+
def _read_version() -> str:
28+
"""Read version from _version.py or the installed package."""
29+
raw = None
30+
31+
# Try 1: Read from source tree (editable install / local dev)
32+
version_file = (
33+
Path(__file__).resolve().parents[2] / "src" / "encoding_atlas" / "_version.py"
34+
)
35+
if version_file.exists():
36+
match = re.search(
37+
r'__version__\s*=\s*version\s*=\s*["\']([^"\']+)["\']',
38+
version_file.read_text(),
39+
)
40+
if match:
41+
raw = match.group(1)
42+
43+
# Try 2: Import from installed package (non-editable pip install in CI)
44+
if raw is None:
45+
try:
46+
from encoding_atlas._version import __version__
47+
48+
raw = __version__
49+
except ImportError:
50+
pass
51+
52+
if raw is None:
53+
return "dev"
54+
55+
return _strip_dev_suffix(raw)
56+
57+
58+
def on_config(config, **kwargs):
59+
"""Inject package_version into extra config for Jinja2 templates."""
60+
config["extra"]["package_version"] = _read_version()
61+
return config

0 commit comments

Comments
 (0)