Type to start searching

Enlightened Measurement
for Modern Science

PyTestLab is a modern Python toolbox for laboratory test-and-measurement automation, data management, and analysis. Move faster, build smarter, and trust your results.

A Toolbox Built for Velocity

Stop wrestling with legacy APIs. Start building reproducible experiments.

Extensible by Design

Maximize instrument uptime and slash test execution times.

Unified Driver Layer

A consistent, high-level API across oscilloscopes, PSUs, DMMs, and more. Swap instruments without rewriting your test logic.

Declarative & Validated

Define instruments and benches with simple YAML files, validated by Pydantic. Catch configuration errors before they hit the hardware.

An API Designed for Flow

Follow the journey from a single command to a complete, automated experiment.

1. Hello, Instrument

Start simple. Connect to any instrument with one line. PyTestLab's AutoInstrument handles the backend, even providing a full simulation for development and CI.

2. Define Your Bench

Describe your entire lab bench in a simple, readable YAML file. Specify instruments, connection details, and software limits for supported settings.

3. Run Your Bench

Bring your bench to life. The `Bench` context manager handles all connections and provides access to your instruments by the aliases you defined. Safety limits are enforced automatically.

4. Design Experiments

Go beyond simple commands. Use MeasurementSession to design complex experiments, sweep multiple parameters, and automatically collect structured data, ready for analysis.

from pytestlab import AutoInstrument

# Take a voltage reading without connecting hardware.
dmm = AutoInstrument.from_config(
    "keysight/34470A", simulate=True
)
try:
    reading = dmm.measure("dc_voltage")
    print(reading.values, reading.units)
finally:
    dmm.close()
# bench.yaml
bench_name: "Power-Amp Characterisation"
simulate: true

instruments:
  psu:
    profile: "keysight/EDU36311A"
    safety_limits:
      channels:
        1: {voltage: {max: 6.0}, current: {max: 3}}
  dmm:
    profile: "keysight/34470A"
import pytestlab
from pytestlab.bench import SafetyLimitError

def run_bench():
    # Context manager handles connections & safety
    with pytestlab.Bench.open("bench.yaml") as bench:

        # Access instruments by their alias
        v = bench.dmm.measure("dc_voltage")
        print(f"Measured: {v.values} {v.units}")

        # Safety limits are automatically enforced
        try:
            bench.psu.set_voltage(1, 7.0)
        except SafetyLimitError as e:
            print(f"Error: {e}")

run_bench()
from pytestlab.measurements import MeasurementSession

# Declaratively build a complex experiment
def run_sweep():
    with MeasurementSession("MOSFET IV Curve") as meas:
        meas.instrument("psu", "keysight/EDU36311A", simulate=True)
        meas.instrument("dmm", "keysight/34470A", simulate=True)

        meas.parameter("v_gate", [0.0, 0.5, 1.0], unit="V")
        meas.parameter("v_drain", [0.1, 1.0, 5.0], unit="V")

        @meas.acquire
        def drain_current(psu, dmm, v_gate, v_drain):
            psu.set_voltage(1, v_gate)
            psu.set_voltage(2, v_drain)
            return dmm.measure("dc_current")

        results = meas.run()
        print(results.data.head())

run_sweep()
Python

Ready to Accelerate Your Research?

PyTestLab is ready for your lab. Get started today and transform how you measure, test, and analyze.