Reference

API Reference

Complete reference for every public class and method in instrumation-report 0.0.1.


On this page

Measurement ReportHeader TestTable Section Report Condition types

Measurement

Dataclass. A single measured value with optional pass/fail evaluation.

FieldTypeDefaultDescription
namestrrequiredLabel for the measurement row.
valuefloatrequiredMeasured numeric value.
unitstr""Unit string, e.g. "V", "Hz", "dB".
conditiontuple | callable | float | NoneNonePass/fail rule. See Condition types.
test_numberstr""Procedure reference, e.g. "1.1.3".
expectedstr""Human-readable expected value, e.g. "3.2–3.4 V".
notesstr""Short annotation shown in the Notes column.
descriptionstr""Longer description (not shown in table by default).

Properties

.evaluate() → bool | None Evaluates the condition. Returns True, False, or None (no condition).
.status → str Returns "PASS", "FAIL", or "N/A" based on evaluate().

ReportHeader

Dataclass. UUT metadata shown in the report header block.

FieldTypeDefaultDescription
titlestrrequiredMain report title.
subtitlestr""Secondary line shown below the title.
engineerstr""Engineer / tester name.
uut_namestr""Name of the unit under test.
uut_serialstr""Serial number of the UUT.
revisionstr""Hardware or firmware revision.
datestrtoday (ISO)Test date. Defaults to datetime.date.today().isoformat().
extra_fieldsdict{}Arbitrary key/value pairs added to the header grid.

TestTable

Dataclass. A numbered table of measurements inside a Section.

FieldTypeDefaultDescription
titlestrrequiredTable heading.
sub_numberstrrequiredSub-section identifier, e.g. "1.1".
measurementslist[Measurement][]Populated via add().
.add(measurement: Measurement) Append a measurement to this table.

Section

Dataclass. A top-level section containing one or more TestTables.

FieldTypeDefaultDescription
numberstrrequiredSection number, e.g. "1", "2".
titlestrrequiredSection heading.
subtitlestr""Optional sub-heading shown below the section title.
tableslist[TestTable][]Populated via add_table().
.add_table(table: TestTable) Append a TestTable to this section.

Report

Main class. Holds the header, sections, and flat measurements. Drives output generation.

ConstructorReport(header: ReportHeader = None)

If header is omitted, a default header with title "Measurement Report" and today's date is used.

.add_section(section: Section) Add a structured section to the report.
.add(measurement: Measurement) Flat backwards-compatible API. Measurements appear after all sections.
.generate_html(path: str) Write a self-contained HTML report. Dependencies: jinja2.
.generate_excel(path: str) Write a structured .xlsx report with coloured rows. Dependencies: openpyxl.
.generate_pdf(path: str) Write an A4 PDF via weasyprint. Requires pip install "instrumation-report[pdf]" and system Pango libraries. Raises ImportError if weasyprint is not installed.

Condition types

The condition argument on Measurement accepts four forms:

TypeExamplePasses whenNotes
Range tuple (3.2, 3.4) lo <= value <= hi Inclusive on both ends
Lambda lambda v: v > 1000 Callable returns truthy Any callable float → bool
Threshold float 15.0 value >= threshold Useful for minimum specs
None omit argument N/A — no evaluation Good for informational rows
Passing an unsupported type (e.g. a string) to condition raises TypeError at evaluation time.