shrinkage 0.4.0

Composable regularized statistical models in Rust.
Documentation
version: "3"

tasks:
  format:
    desc: Format source and documentation
    cmds:
      - cargo fmt --all
      - cargo fmt --manifest-path packages/python/Cargo.toml
      - cargo fmt --manifest-path docs/widget/Cargo.toml
      - ruff format packages/python scripts
      - ruff check --fix packages/python scripts
      - panache format .

  lint:
    desc: Lint source and documentation
    cmds:
      - cargo clippy --locked --all-targets --all-features -- -D warnings
      - task: python:lint
      - panache lint .

  test:
    desc: Test versioned backends and their aliases
    cmds:
      - cargo test --locked --no-default-features
      - cargo test --locked --no-default-features --features faer_v0_24
      - cargo test --locked --no-default-features --features nalgebra_v0_34
      - cargo test --locked --no-default-features --features ndarray_v0_17
      - cargo test --locked --no-default-features --features sprs_v0_11
      - cargo test --locked --no-default-features --features faer
      - cargo test --locked --no-default-features --features nalgebra
      - cargo test --locked --no-default-features --features ndarray
      - cargo test --locked --no-default-features --features sprs
      - cargo test --locked --no-default-features --features zarrs_v0_22
      - cargo test --locked --no-default-features --features zarrs
      - cargo test --locked --no-default-features --features experimental-block-reader,zarrs_v0_22
      - cargo test --locked --all-features

  example:
    desc: Verify fitting examples and Rust/Python fixtures
    cmds:
      - cargo run --locked --example normalization --features faer_v0_24
      - cargo run --locked --example lasso --features faer_v0_24
      - cargo run --locked --example binomial --features faer_v0_24
      - cargo run --locked --example multivariate --features faer_v0_24
      - cargo run --locked --example group_lasso --features faer_v0_24
      - cargo run --locked --example clustered_lasso --features faer_v0_24
      - cargo run --locked --example chain_fused_lasso --features faer_v0_24
      - cargo run --locked --example slope --features faer_v0_24
      - cargo run --locked --example regularization_path --features faer_v0_24
      - cargo run --locked --example cross_validation --features faer_v0_24
      - cargo run --locked --example python_lasso_fixture --features ndarray_v0_17 -- --check
      - cargo run --locked --example python_model_fixture --features ndarray_v0_17 -- --check
      - cargo run --locked --example python_path_fixture --features ndarray_v0_17 -- --check
      - cargo run --locked --example zarrs_buffered --features experimental-block-reader,zarrs_v0_22

  bench:
    desc: Benchmark Gaussian lasso with only the faer backend enabled
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench lasso

  bench:heap:
    desc: Measure lasso allocations and peak live heap with linear memory budgets
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench lasso_heap

  bench:irls:
    desc: Benchmark binomial IRLS and proximal gradient with dense and CSC input
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench irls

  bench:irls:heap:
    desc: Verify linear IRLS workspace and reuse across coordinate sweeps
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench irls_heap

  bench:hybrid:irls:
    desc: Compare complete logistic hybrid IRLS and proximal fits
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench hybrid_irls

  bench:hybrid:irls:heap:
    desc: Check logistic weighted aggregate storage across quadratic models
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench hybrid_irls_heap

  bench:paths:
    desc: Compare complete warm HybridCoordinateDescent paths and cold fits, including heap usage
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench hybrid_paths

  bench:proximal:
    desc: Benchmark proximal vector and multivariate fits with dense and CSC input
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench proximal

  bench:proximal:heap:
    desc: Measure normalized products, proximal maps, and path allocations
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench proximal_heap

  bench:proximal:buffers:
    desc: Separate native vector copies from normalized proximal products
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24,nalgebra_v0_34,ndarray_v0_17 --bench proximal_buffers -- {{.CLI_ARGS}}

  bench:slope:
    desc: Benchmark exact SLOPE proximal maps with distinct and tied magnitudes
    cmds:
      - cargo bench --locked --no-default-features --bench slope

  bench:slope:hybrid:
    desc: Compare complete SLOPE hybrid and proximal fits at matched accuracy
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench slope_hybrid

  bench:slope:heap:
    desc: Check SLOPE proximal scratch reuse and dense magnitude-cluster storage
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench slope_hybrid_heap

  bench:groups:
    desc: Benchmark weighted Group LASSO values, proximal maps, and Gaussian fits
    cmds:
      - cargo bench --locked --no-default-features --bench group_lasso
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench proximal -- group_lasso

  bench:clustered:
    desc: Compare complete clustered-lasso hybrid and proximal fits
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench clustered_lasso

  bench:clustered:heap:
    desc: Measure clustered-lasso scratch reuse and dense aggregate storage
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench clustered_lasso_heap

  bench:chain:
    desc: Compare weighted chain proximal operations and complete hybrid fits
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench chain_fused_lasso

  bench:chain:heap:
    desc: Check chain proximal scratch reuse and dense segment storage
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench chain_fused_lasso_heap

  bench:working-sets:
    desc: Compare working-set policies on complete fits and paths
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench working_sets -- {{.CLI_ARGS}}

  bench:screening:
    desc: Compare dynamic screening time and heap at matched original accuracy
    cmds:
      - cargo bench --locked --no-default-features --features faer_v0_24 --bench screening -- {{.CLI_ARGS}}

  bench:scaled:
    desc: Compare scaled penalty values and proximal maps with built-in strengths
    cmds:
      - cargo bench --locked --no-default-features --bench scaled

  bench:masked:
    desc: Benchmark penalty values and proximal maps with unpenalized coordinates
    cmds:
      - cargo bench --locked --no-default-features --bench masked

  bench:rows:
    desc: Benchmark scaled and masked penalties on feature rows
    cmds:
      - cargo bench --locked --no-default-features --bench row_composition

  check:
    desc: Run all required checks
    cmds:
      - cargo fmt --all -- --check
      - cargo clippy --locked --all-targets --all-features -- -D warnings
      - cargo build --locked --no-default-features
      - task: test
      - task: example
      - task: bench:heap
      - task: bench:irls:heap
      - task: bench:hybrid:irls:heap
      - task: bench:proximal:heap
      - task: bench:clustered:heap
      - task: bench:chain:heap
      - task: bench:slope:heap
      - RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps --all-features
      - panache format --check .
      - panache lint .
      - task: python:check
      - task: python:artifacts
      - task: releases:check

  releases:check:
    desc: Verify independent versions and release PRs in disposable repositories
    cmds:
      - npm --prefix docs ci --ignore-scripts
      - npm --prefix docs run check:releases

  python:install:
    desc: Build and install the editable Python package and development tools
    cmds:
      - uv sync --locked --project packages/python --reinstall-package shrinkage

  python:bench:
    desc: Plot Python lasso convergence at one regularization strength
    cmds:
      - uv sync --locked --project packages/python --group benchmark --reinstall-package shrinkage --config-settings-package 'shrinkage:build-args=--profile release'
      - uv run --no-sync --project packages/python pytest packages/python/benchmarks
      - uv run --no-sync --project packages/python python packages/python/benchmarks/report.py --run

  python:bench:check:
    desc: Check benchmark reporting and the saved plot without taking timings
    cmds:
      - uv run --locked --project packages/python --group benchmark pytest packages/python/benchmarks
      - uv run --locked --project packages/python --group benchmark python packages/python/benchmarks/report.py --check

  python:lint:
    desc: Check Python formatting, types, and native binding lints
    deps: [python:install]
    cmds:
      - cargo fmt --manifest-path packages/python/Cargo.toml -- --check
      - cargo clippy --locked --manifest-path packages/python/Cargo.toml --all-targets -- -D warnings
      - ruff format --check packages/python scripts
      - ruff check packages/python scripts
      - uv run --locked --project packages/python mypy --config-file packages/python/pyproject.toml packages/python/src/shrinkage packages/python/tests scripts/check_python_artifacts.py

  python:check:
    desc: Check and test the Python package
    cmds:
      - task: python:lint
      - uv run --locked --project packages/python pytest packages/python/tests

  python:artifacts:
    desc: Test installed wheels and a wheel rebuilt from an isolated sdist
    cmds:
      - python scripts/check_python_artifacts.py --sdist

  docs:widget:build:
    desc: Build the browser explorer from the Rust solvers
    sources:
      - src/**/*.rs
      - Cargo.toml
      - docs/widget/Cargo.toml
      - docs/widget/Cargo.lock
      - docs/widget/src/**/*.rs
      - docs/widget/web/*
      - docs/widget/package.json
      - docs/widget/package-lock.json
      - docs/widget/build.mjs
      - rust-toolchain.toml
    generates:
      - docs/widget/dist/index.js
      - docs/widget/dist/worker.js
      - docs/widget/dist/style.css
      - docs/widget/dist/shrinkage_widget_bg.wasm
      - docs/widget/pkg/shrinkage_widget.js
    cmds:
      - cargo build --locked --manifest-path docs/widget/Cargo.toml --release --lib --target wasm32-unknown-unknown
      - wasm-bindgen docs/widget/target/wasm32-unknown-unknown/release/shrinkage_widget.wasm --target web --out-dir docs/widget/pkg --out-name shrinkage_widget
      - npm --prefix docs/widget ci --ignore-scripts
      - npm --prefix docs/widget run build

  docs:widget:figure:
    desc: Regenerate the static explorer illustration
    cmds:
      - uv run --script scripts/optimization_figure.py

  docs:widget:check:
    desc: Verify solver traces, WebAssembly parity, and browser interaction
    cmds:
      - cargo fmt --manifest-path docs/widget/Cargo.toml -- --check
      - cargo clippy --locked --manifest-path docs/widget/Cargo.toml --all-targets -- -D warnings
      - cargo test --locked --manifest-path docs/widget/Cargo.toml
      - task: docs:widget:build
      - npm --prefix docs/widget test
      - uv run --script scripts/optimization_figure.py --check
      - npm --prefix docs/widget run test:browser

  docs:prepare:
    internal: true
    cmds:
      - cp CONTRIBUTING.md docs/pages/contributing.md
      - task: python:install
      - cargo fetch --locked

  docs:serve:
    desc: Preview the shared Rust and Python documentation
    deps: [docs:prepare, docs:widget:build]
    cmds:
      - uv run --locked --project packages/python diplodocus serve --config docs/diplodocus.yaml --output docs/site

  docs:figures:
    desc: Regenerate the penalty constraint figures
    cmds:
      - uv run --script scripts/penalty_regions.py

  docs:figures:check:
    desc: Verify penalty geometry and committed constraint figures
    cmds:
      - uv run --script scripts/penalty_regions.py --check

  docs:build:
    desc: Validate and build the shared documentation site
    deps: [docs:prepare, docs:widget:build]
    cmds:
      - uv run --locked --project packages/python diplodocus check --config docs/diplodocus.yaml
      - uv run --locked --project packages/python diplodocus build --config docs/diplodocus.yaml --output docs/site
      - python scripts/prepare_documentation.py

  docs:check:
    desc: Build documentation and verify its explorer and Cloudflare Worker package
    cmds:
      - task: docs:widget:check
      - task: docs:figures:check
      - task: docs:build
      - npm --prefix docs ci --ignore-scripts
      - npm --prefix docs run check
      - SHRINKAGE_DOCS_SITE="{{.ROOT_DIR}}/docs/site" npm --prefix docs/widget run test:browser