Skip to content

About

Python template for single-method computational research: algorithms in src/, seeded experiments, auto-generated figures, and a manuscript where every number is a token filled from code. uv, pytest, and Zenodo/PyPI/arXiv publishing.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Code Project — Optimization Research Exemplar

Research project demonstrating optimization algorithms with automated figure generation and publication-quality output. Exemplar roster: projects/AGENTS.md.

When to use this template

Use this template for code-driven computational research: algorithms in src/, numerical experiments with deterministic seeds, automated publication-quality figures, and a manuscript that reports the computed results. It demonstrates the thin-orchestrator pattern (scripts coordinate; src/ implements; tests enforce ≥90% coverage with no mocks). If your project is primarily prose review, layout, or book-length structure, see template_prose_project, template_newspaper, or template_textbook instead.

Publication and rendering

The publishing metadata and per-platform status below are compiled from docs/manuscript/config.yaml by infrastructure.publishing.status_report — do not hand-edit between the markers; update the config and regenerate (see the legend).

Convergence Analysis of Gradient Descent Optimization · intended v3.0.0 (unreleased) · MIT · Daniel Ari Friedman

Intended release: v3.0.0 — unreleased. Last published release: v2.5.2. Recorded publication links refer to that release.

Concept DOI: 10.5281/zenodo.20417136 | Last published version DOI: 10.5281/zenodo.20931934 | Repository: docxology/template_code_project

Publishing surface — 20 platforms, 0 published for the intended release:

Platform Tier Status Reference Credentials
zenodo first-class 📚 historical reference 10.5281/zenodo.20417136 ZENODO_API_TOKEN
github first-class 📚 historical reference docxology/template_code_project GITHUB_TOKEN
arxiv first-class ⚪ available — —
pypi first-class 📚 historical reference https://test.pypi.org/project/template-code-project/2.5.2/ PYPI_TOKEN, TESTPYPI_TOKEN
ipfs_pinata first-class 📚 historical reference https://gateway.pinata.cloud/ipfs/QmSVZF1MisqWeX1C7vFUhcwCkYvZXBuq5TS9MzLFNJJykS PINATA_JWT
ipfs_web3storage first-class ⚪ available — WEB3_STORAGE_TOKEN
software_heritage first-class 📚 historical reference https://archive.softwareheritage.org/browse/origin/?origin_url=https://github.com/docxology/template_code_project —
github_pages first-class 📚 historical reference https://docxology.github.io/template_code_project/ GITHUB_TOKEN
cloudflare_pages first-class ⚪ available — CLOUDFLARE_API_TOKEN
netlify first-class 📚 historical reference https://6a4440a789b44ad53f3af09b--tranquil-kleicha-0c9203.netlify.app NETLIFY_AUTH_TOKEN
huggingface_hub first-class 📚 historical reference https://huggingface.co/datasets/ActiveInference/template_code_project HUGGINGFACE_TOKEN, HF_TOKEN
osf first-class 📚 historical reference https://osf.io/mcv8j/ OSF_TOKEN
amazon_kdp documented 🟡 planned — AMAZON_KDP_EMAIL, AMAZON_KDP_PASSWORD
google_play_books documented 🟡 planned — GOOGLE_PLAY_BOOKS_SERVICE_ACCOUNT_JSON
gumroad documented 🟡 planned — GUMROAD_ACCESS_TOKEN
leanpub documented 🟡 planned — LEANPUB_API_KEY
lulu documented 🟡 planned — LULU_CLIENT_KEY, LULU_CLIENT_SECRET
draft2digital documented 🟡 planned — DRAFT2DIGITAL_API_TOKEN
stripe documented 🟡 planned — STRIPE_SECRET_KEY, STRIPE_PUBLISHABLE_KEY
ingramspark documented 🟡 planned — INGRAMSPARK_CLIENT_ID, INGRAMSPARK_CLIENT_SECRET

Keywords: optimization algorithms, gradient descent, convergence analysis, numerical methods, mathematical programming, reproducible research, infrastructure automation.

Status legend: ✅ published (durable identifier recorded in config.yaml) · 🔵 reserved (identifier reserved but not yet registered by final publication) · 📚 historical reference (last published release; not intended-version publication evidence) · ⚪ available (adapter implemented and locally verifiable) · 🟡 planned. This block is generated — edit docs/manuscript/config.yaml, then regenerate with uv run python -m infrastructure.publishing.status_report --project <path> --write.

The 3 platforms still shown ⚪ available are not automatable to "published" with current tooling/credentials, not an oversight: arXiv has no submission API in this codebase (infrastructure.publishing.arxiv only prepares a local tarball — a human must upload it via arxiv.org and the resulting arxiv URL would then be added to publication.published_artifacts); Cloudflare Pages needs a CLOUDFLARE_ACCOUNT_ID the configured API token cannot auto-discover; IPFS (Web3.Storage) has no WEB3_STORAGE_TOKEN configured.

  • Canonical renderer: docxology/template with --project working/template_code_project for this standalone checkout
  • Tracked outputs: output/ in this project and output/templates/template_code_project/ in the monorepo; public output files above 50 MB stay out of git.

Get started

The documentation index covers setup, the optimizer, publication settings, and reuse. Follow the quick start for Python 3.12+ standalone setup, the test suite and numerical analysis. The guide also prepares a separate Python 3.14 environment for rendering and validation with the pinned Template.

The maintained manuscript lives in docs/manuscript/. Its configuration selects the experiment and publication formats. See the output inventory for artifact locations and the standalone guide for forking and upstream template integration.

Agentic research overlays

This exemplar includes two declarative overlays for advisory research controls:

  • domain_profile.yaml declares the code-research domain, expected outputs, review gates, source policy, artifact expectations, and benchmark rubric weights.
  • experiment_plan.yaml declares the deterministic gradient-descent conditions, primary metric direction, expected figures and tables, baseline, and ablation condition.
  • data/claim_ledger.yaml registers manuscript numeric claims that are intentionally sourced from project code, captions, or generated artifacts rather than {{TOKEN}} variables.

These files are validation and benchmark inputs only. They do not fork project trees, mutate prompts, or run autonomous experiment agents.

Why this template — the transferable pattern

The genuinely transferable lesson is not gradient descent. It is reproducibility-by-construction: every numeric in the manuscript prose is a {{TOKEN}} registered in one Python function (src/template_code_project/core/manuscript_variables.py::generate_variables) and cross-checked by one test (tests/core/test_manuscript_variables.py::test_all_manuscript_tokens_are_generated), which fails CI on any token used in prose that the generator does not emit. The deliverable PDF is therefore proof that the repo's invariants held during build: configuration drift, deleted result, or out-of-sync narrative cannot reach a green PDF without the gate flipping red first. A forker who internalizes "every prose number is a token, every token is a single Python function, every drift is a CI failure" gets that discipline for free — regardless of whether their domain is optimization.

Key Features

  • Gradient descent optimization with convergence analysis
  • Automated figure generation (convergence plots, stability analysis, performance benchmarks)
  • Scientific validation (numerical stability assessment, performance benchmarking)
  • Comprehensive reporting (HTML dashboard with analysis metrics)
  • Performance monitoring (resource usage tracking with progress indicators)
  • Data export (optimization results, analysis reports, performance metrics)
  • Manuscript integration (figure registration and cross-referencing)

Common Commands

Run these from the standalone checkout after completing the quick-start setup. Use a disposable checkout when regenerating the tracked publication outputs.

Run Analysis

uv run python scripts/optimization_analysis.py

Generates convergence plots, performs scientific validation, and saves all results.

Build Dashboard

uv run python scripts/build_dashboard.py

The dashboard computes its data from the experiment configuration. Use --max-iter to raise the iteration cap for smaller custom step sizes. Module guide

Run Tests

uv run --locked --extra dev pytest tests/ --cov --cov-config=pyproject.toml --cov-fail-under=90

Tests optimization algorithms and numerical accuracy.

View Results

open output/figures/convergence_plot.png
cat output/data/optimization_results.csv

Architecture

graph TD
    A[scripts/optimization_analysis.py] --> B[src/template_code_project/analysis/]
    B --> C[src/template_code_project/core/optimizer.py]
    B --> D[Scientific Analysis]
    B --> E[Generate Figures]
    B --> F[Export Data]
    B --> G[Create Dashboard]

    AA[scripts/generate_api_docs.py] --> AB[API Documentation]
    AA --> AC[Code Quality Report]

    C --> H[Gradient Descent]
    C --> I[Quadratic Functions]
    C --> J[Convergence Analysis]

    D --> K[Stability Assessment]
    D --> L[Performance Benchmarking]
    D --> M[Progress Monitoring]

    E --> N[Convergence Plots]
    E --> O[Stability Visualizations]
    E --> P[Benchmark Charts]

    G --> Q[HTML Dashboard]
    G --> R[Analysis Reports]

    F --> S[CSV Results]
    F --> T[JSON Reports]
Loading

Development and agent guidance

Shared instructions live in root AGENTS.md and .agents/AGENTS.md. The following development standards apply:

  • Testing: src/ coverage is gated at 90% (suite contract in docs/testing_philosophy.md)
  • Documentation: AGENTS.md + README.md in each directory
  • Type Safety: Full type hints on all public APIs
  • Code Quality: Ruff format/check (CI parity), descriptive naming, proper imports
  • Error Handling: Context preservation, informative messages
  • Logging: Unified logging system throughout

Manuscript authoring

When editing manuscript markdown:

More Information

See AGENTS.md for technical documentation.

Template integrity

  • Forward backlog: TODO.md.
  • Copy-and-customize config: docs/manuscript/config.yaml.example.
  • Validate the project from the standalone checkout root with uv run --locked --extra dev pytest tests/ --cov --cov-config=pyproject.toml --cov-fail-under=90.
  • Check drift for the bundled exemplar from the Template checkout root with uv run python scripts/audit/check_template_drift.py --project templates/template_code_project --strict.

Optional hardening

Default CI builds this template's wheel and runs focused behavioral tests. Further hardening can add optimization stability across seeds and larger convergence sweeps. The complete suites and native/provider acceptance remain opt-in; see functional CI and hardening for commands and the evidence each lane establishes.

About

Python template for single-method computational research: algorithms in src/, seeded experiments, auto-generated figures, and a manuscript where every number is a token filled from code. uv, pytest, and Zenodo/PyPI/arXiv publishing.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages