Numeric
Record numeric values with range validation.
You can create a numeric measurement with measurements:
measurements:
- name: Output Voltage
unit: V
validators:
- operator: ">="
expected_value: 4.8
- operator: "<="
expected_value: 5.2You can set the measurement value in your Python phase:
def measure_voltage(run, measurements, multimeter):
voltage = multimeter.read_voltage()
measurements.output_voltage = voltage Definition
You can configure the measurement name and metadata.
| Property | Type | Required | Description |
|---|---|---|---|
key | string | No | Unique identifier for the measurement within the phase |
name | string | Yes | Display name (1-100 characters) |
unit | string | No | Measurement unit (e.g., "V", "A", "°C", max 50 characters) |
description | string | No | Detailed description (max 50,000 characters) |
TofuPilot auto-generates the key from name (snake_case) if not specified, and uses it for Python access (e.g., measurements.output_voltage). The unit and description display in the web interface and reports.
Validators
You can add one or several validators to your measurement using the following properties:
| Property | Type | Required | Description |
|---|---|---|---|
operator | string | Yes | Comparison operator |
expected_value | number or array | Yes | Expected value(s) for comparison |
You can use the following operators for numeric measurements:
| Operator | Expected Value | Description | Example |
|---|---|---|---|
== | Number | Value must equal expected | expected_value: 5.0 |
!= | Number | Value must not equal expected | expected_value: 0.0 |
> | Number | Value must be greater than | expected_value: 4.8 |
>= | Number | Value must be greater than or equal | expected_value: 4.8 |
< | Number | Value must be less than | expected_value: 5.2 |
<= | Number | Value must be less than or equal | expected_value: 5.2 |
in | Array of numbers | Value must be in the array | expected_value: [5.0, 12.0, 24.0] |
not in | Array of numbers | Value must not be in the array | expected_value: [0.0, -1.0] |
TofuPilot evaluates validators and sets the outcome to Pass if met, Fail if not, or Unset if no value provided.
You can use Aggregations for statistical validation on numeric arrays.
Examples
Voltage Measurement
We will measure output voltage with min/max limits:
phases:
- name: Power Supply Test
python:
module: measure_voltage
measurements:
- name: Output Voltage
unit: V
description: Main power supply output voltage
validators:
- operator: ">="
expected_value: 4.8
- operator: "<="
expected_value: 5.2def measure_voltage(run, multimeter):
log.info("Measuring output voltage")
voltage = multimeter.read_voltage()
measurements.output_voltage = voltage
if voltage < 4.8 or voltage > 5.2:
log.warning(f"Voltage out of spec: {voltage} V")Set Point Validation
We will validate voltage is one of the allowed setpoints:
phases:
- name: Voltage Check
python:
module: check_voltage
measurements:
- name: Output Voltage
unit: V
description: Verify output matches one of the valid setpoints
validators:
- operator: in
expected_value: [5.0, 12.0, 24.0]def check_voltage(run, multimeter):
log.info("Checking voltage setpoint")
voltage = multimeter.read_voltage()
measurements.output_voltage = voltage
if voltage not in [5.0, 12.0, 24.0]:
log.warning(f"Unexpected voltage: {voltage} V")How is this guide?