Skip to main content

PyBlackwell

Blackwell approachability primitives for finite vector-payoff games, with explicit numerical certificates and reproducible experiment tooling.

PyPI version Supported Python versions GitLab pipeline MIT license

Documentation · PyPI · Examples · Changelog · Security

PyBlackwell connects target-set geometry, finite games, minimax action selection, repeated-game solvers, and diagnostics in one NumPy-first API. The classical path covers bounded finite vector-payoff games, closed convex targets, full-information or expected-payoff updates, and exact or tolerance-controlled projection and minimax oracles. Extensions for calibration, partial feedback, online learning, and RL expose their additional assumptions instead of presenting numerical diagnostics as stronger guarantees.

Install

Install the base package, which depends only on NumPy, SciPy, and typing-extensions:

python -m pip install pyblackwell

PyBlackwell requires Python 3.10 or newer. The project CI currently tests CPython 3.10, 3.11, and 3.12 on Linux.

Quick start

This matching game has scalar payoffs -1 and 1; mixing both learner actions equally keeps the running payoff average at the point target {0}.

import numpy as np

from pyblackwell import BlackwellApproachability, MatrixGame, PointTarget

payoffs = np.array(
    [
        [[-1.0], [1.0]],
        [[1.0], [-1.0]],
    ]
)

game = MatrixGame(payoffs)
solver = BlackwellApproachability(game, PointTarget([0.0]))

for env_action in [0, 1] * 25:
    strategy = solver.strategy()
    solver.update(game.payoff(strategy, env_action), env_action=env_action)

certificate = solver.certificate()
print(
    {
        "iterations": certificate.iteration,
        "average": certificate.average.tolist(),
        "distance": certificate.distance,
    }
)
{'iterations': 50, 'average': [0.0], 'distance': 0.0}

The certificate records the running average, target projection, distance, separating normal, numerical status, and decision-time oracle result. Use solver.trace() for per-iteration histories or summary_only=True for bounded memory when only aggregate diagnostics are needed.

Why PyBlackwell?

  • Closed-form and optimization-backed targets expose projection, containment, support, and separation through consistent result objects.
  • Classical, OCO, regret-reduction, predictive, delayed, and adaptive solver variants share explicit state, certificate, and trace conventions.
  • Full-information, bandit, and partial-monitoring helpers keep observation assumptions visible in diagnostics.
  • Optional integrations stay behind extras and lazy imports, so the base package remains lightweight.
  • Seeded examples, trace archives, benchmark metadata, and experiment manifests support reproducible numerical work.
  • Stable, experimental, and private import paths are documented explicitly.

Compatibility and optional extras

Extra Capability
cvx CVXPY-backed convex and semidefinite targets
diffopt CVXPYLayers and JAXopt differentiable projections
torch, jax, pandas Result and trace adapters
rl Gymnasium vector-reward integration
sklearn scikit-learn calibration adapters
plot Matplotlib convergence and calibration plots

Install only what a workflow needs, for example:

python -m pip install "pyblackwell[cvx,plot]"

PyBlackwell is currently an alpha 0.x project. The API policy identifies supported and experimental namespaces; pin a version when relying on experimental modules or numerical backend behavior.

Scope and limitations

PyBlackwell is for target-set approachability and related online-learning reductions. It is not a general convex optimization toolkit, an extensive-form game solver, or a proof that an arbitrary bandit or RL training loop satisfies the classical Blackwell assumptions. External game packages should own trees, information sets, CFR, sequence-form optimization, and equilibrium claims, with PyBlackwell consuming validated payoff or regret records through adapters.

Certificates describe the numerical computation that ran. Exact finite-game, approximate-oracle, bandit, sampled-calibration, and RL claims have different assumptions. Read the guarantee boundaries before interpreting positive residuals, approximation statuses, or realized sample paths.

Documentation

Packaged example configurations and saved traces also have command-line entry points:

pyblackwell-example --list
pyblackwell-example matching-pennies-point
pyblackwell-trace-summary path/to/trace.npz
pyblackwell-benchmark run --mode smoke --iterations 20

Reproducible research

Library examples teach supported APIs; benchmarks/ tracks stable performance workloads; experiments/ evaluates scientific claims. Generated runs are not source files and belong under the ignored runs/ directory.

The corrected article experiment uses a frozen protocol, disjoint validation and test decisions, explicit seed streams, environment and source provenance, and checksummed result bundles:

OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 \
PYTHONPATH=src python experiments/article_contract_monitor_v2.py \
  --profile smoke --output-dir runs/article_v2_smoke

Use the immutable article profile only from a clean checkout. See the experiment policy, frozen protocol, and correction note. The comparison does not claim that Blackwell eliminates scalarization, and it keeps expected-update calibration separate from realized forecast error.

Support and development

Use the issue tracker for reproducible bugs and scoped feature requests. Read SUPPORT.md for the information to include and SECURITY.md for private vulnerability reporting.

Contributors can create the locked environment and run the same command contract used by CI:

uv sync --locked
make check
make package-check

Read the contribution guide and code of conduct before opening a merge request.

License and citation

PyBlackwell is released under the MIT License. For research use, cite the software using CITATION.cff and pin the release version used by the experiment.

Metadata

Release files for pyblackwell 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyblackwell 0.1.2
File Size Uploaded
pyblackwell-0.1.2.tar.gz 411.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyblackwell 0.1.2
File Interpreter ABI Platform
pyblackwell-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 589.7 kB

Release files / pyblackwell-0.1.2.tar.gz

Download URL pyblackwell-0.1.2.tar.gz
Size 411.8 kB
Tags Source
SHA-256 checksum
How to use checksums
388765d2924d000db52ef3828fb472024c2a0bc6742406545d496a0849fd65b1
BLAKE2b-256 checksum
How to use checksums
56d6c50874dc2d62d17e42077390d52dc3db7a98debf41c1fcad050b54e3f4c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pyblackwell-0.1.2-py3-none-any.whl

Download URL pyblackwell-0.1.2-py3-none-any.whl
Size 177.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
999a3fa3f5787c8a15e0e073ea544434b7fba453c006d8bc922ec1a496e11aae
BLAKE2b-256 checksum
How to use checksums
16945eadb9c86c6154da99338b60de605d627a44f7633db2d819d9066032fc83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page