Skip to main content

PowerContract

PyPI version Python versions CI License

PowerContract checks waveform CSV files against electrical requirements defined in YAML.

You map capture columns to named signals, choose threshold events, and define voltage or timing limits. Events can require a stable interval; voltage limits can apply to the whole capture or between two events. Rise and fall times, measurement uncertainty and requirement references are also defined in the contract.

The same contract can be run against later captures with the same signal mapping. Each requirement returns PASS, FAIL, or INDETERMINATE, with its measured value, limit and margin. Missing events and uncertainty intervals that cross a limit remain indeterminate.

PowerContract is deliberately small. Oscilloscopes and commercial power-analysis suites already provide broad measurement workflows; this tool focuses on checking recorded signals against requirements you can keep in version control and run again. It doesn't control instruments, estimate uncertainty or interpret datasheets.

Project overview · Engineering note: why I wrote it

Install

python -m pip install powercontract
powercontract --version

If you cloned the repository, you can also run the bundled example:

powercontract check examples/boot.csv examples/boot.yaml

For your own capture, inspect the CSV first and use its actual column names in the contract. The getting-started guide walks through the full process.

Example contract

version: 1

capture:
  time_column: Time

signals:
  vdd:
    column: VDD_3V3
    nominal: 3.3

  en:
    column: EN
    nominal: 3.3

events:
  vdd_valid:
    signal: vdd
    direction: above
    threshold: 3.0

  en_release:
    signal: en
    direction: above
    threshold: 2.0

requirements:
  - id: PWR-001
    type: delay
    from: vdd_valid
    to: en_release
    min: 50us
    source: "Board power specification, section 3.2"

  - id: PWR-002
    type: max_value
    signal: vdd
    value: 3.6
    uncertainty: 0.03

Run it with:

powercontract check capture.csv power.yaml

Write a JSON report with:

powercontract check capture.csv power.yaml --json report.json

Requirements supported in v0.1

Contract version 1 uses seconds for time and volts for signal values.

  • delay between named threshold events;
  • minimum and maximum voltage;
  • event-bounded voltage windows;
  • rise time and fall time;
  • threshold stability windows;
  • explicit measurement uncertainty;
  • optional requirement source;
  • terminal and JSON output.

If the capture does not contain enough evidence to evaluate a requirement, the result is INDETERMINATE.

Capture formats

Input Support
Normal table CSV with one time column and named signal columns Supported
Siglent SDS800X HD per-channel CSV Tested with hardware from this series
Older Siglent / WaveAce-style Source + units CSV Parser tested against documented/public examples
Rigol sequence CSV with Start / Increment Parser tested against public format examples
Rigol paired XY CSV Parser tested against public format examples
Tektronix five-column CSV Parser tested against the Tektronix-documented layout
Keysight InfiniiVision multi-channel CSV Supported through the normal table CSV loader when the file contains named columns
CSV from Python, pandas, MATLAB, LabVIEW, or custom acquisition code Supported through the normal table CSV loader

Only the SDS800X HD per-channel parser has been tested with physical hardware in this project. Other vendor-specific formats have parser tests, not instrument-by-instrument hardware coverage.

See Input formats and Oscilloscope vendor notes for details.

Documentation

Exit codes

Code Meaning
0 all requirements passed
1 at least one requirement failed or was indeterminate
2 invalid capture, contract, or output request

Scope

PowerContract answers one question: did the measured signals satisfy the declared electrical requirements?

It is not a waveform viewer, protocol decoder, SCPI control framework, automatic datasheet parser, or golden-waveform comparison tool.

Development

git clone https://github.com/sidelobe-labs/powercontract.git
cd powercontract
python -m pip install -e '.[dev]'
pytest

CI runs the test suite on Python 3.11 and 3.12, builds the package, runs twine check, and installs the built wheel in a clean virtual environment.

Contributing

See CONTRIBUTING.md. Security issues should follow SECURITY.md.

License

MIT. See LICENSE.

Release history is in CHANGELOG.md.

Metadata

Release files for powercontract 0.1.3

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

Source distribution (sdist)

Source distribution for powercontract 0.1.3
File Size Uploaded Provenance Actions
powercontract-0.1.3.tar.gz 32.1 kB With provenance Details for powercontract-0.1.3.tar.gz

Built distribution (wheel)

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

Total release size: 51.7 kB

Release files / powercontract-0.1.3.tar.gz

Download URL powercontract-0.1.3.tar.gz
Size 32.1 kB
Tags Source
SHA-256 checksum
How to use checksums
102f1edf8e93e44907e6f8f1ae1a91b53835375cd0887eb248dd6746ff19ad75
BLAKE2b-256 checksum
How to use checksums
8ddbc7d054dcdbf4141d7a8a6416ec259067d008caaf316a48a5fda17b64885a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / powercontract-0.1.3-py3-none-any.whl

Download URL powercontract-0.1.3-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
adbbb229376994462c299d7f3560a8df82e26ad4273adbfc2474dec2ed4b6bfb
BLAKE2b-256 checksum
How to use checksums
98665f1ffac5f46e306f62c58803661360995554c929406b7d7db009a819d37b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for powercontract 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for powercontract-0.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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