Skip to content

hertzforge.core.findings

findings

Findings: deviations, anomalies and nonconformances, each in four parts.

A test report writes every departure from the plan (a deviation), every unexpected observation (an anomaly) and every requirement not met (a nonconformance) in the same four parts, in this order: the fact (what happened, on which run, channel and band, by how much, and the record that shows it), the cause as far as it is known, the effect on what the test proves, and the approval of a deviation or the disposition of an anomaly or nonconformance, with who and under which authority. Each carries a number of its kind (D-1, A-1, NC-1) that the summary, the result table and the record refer to.

This module holds the rules a finding is checked against, wherever it is entered: the kinds and their numbers (KINDS, number, next_number), what a finding holds (clean, which refuses what cannot be read one way), which of its parts are still owed (owed), the sentences by which an author says a kind has none (NONE_SENTENCES, declared), and the one part a program can offer: a fact read off a measurement (excursions), the band, side and size by which a channel left one pair of limits.

Only the fact is ever offered, and only as a draft the author accepts or edits. Cause, effect and approval are the author's words, and so is "none": an empty register is not a statement that nothing happened.

Classes:

Name Description
Excursion

One stretch of a channel outside one limit.

ExcursionReading

What excursions read: the stretches outside the limits, in

Functions:

Name Description
kind_of

value as one of KINDS; ValueError naming the kinds for

number

(kind, n) for a finding's number such as 'D-2' or 'NC-1'.

next_number

The number the next finding of kind takes: one past the

issued_of

The highest number issued of each kind, by prefix ({'D': 3}), as

band_of

A band as [low, high] in Hz, or None for none.

clean_draft

A fact draft as stored on a finding: 'text' (required, not

clean

A finding as it is stored, every field present and checked.

read

A register as stored (a list of findings), each clean, in the

owed

The parts of a finding still owed, in order: each of fact, cause,

declared

The kinds an author's words say there are none of: each kind

withdraw

text with the none sentence of each kind in kinds taken out,

declaration

The none sentences of kinds, in the order of KINDS.

pair_records

(specification record, measured record) for channel, paired the

excursions

Where one measured record went outside one pair of limits.

Classes

Excursion dataclass

Excursion(side: str, low: float, high: float, lines: int, worst_db: float)

One stretch of a channel outside one limit.

side is 'above' (over the upper limit) or 'below' (under the lower). low and high are the first and last measured lines in the stretch, in Hz; lines how many lines it holds. worst_db is how far beyond the limit it went at most, as a ratio of density in dB (ten log ten), positive; infinite where a line below a lower limit holds no power at all.

ExcursionReading dataclass

ExcursionReading(excursions: tuple[Excursion, ...], judged: int, low: float, high: float, unjudged: int, scale_db: float)

What excursions read: the stretches outside the limits, in frequency order; how many cells were judged and over what range (judged, low, high); how many measured lines with no value (NaN) were passed over where the specification is written and in the band asked (unjudged); and the scale the measurement was compared at (scale_db).

Functions:

kind_of

kind_of(value: Any) -> str

value as one of KINDS; ValueError naming the kinds for anything else, TypeError for a value that is not a string.

number

number(text: Any) -> tuple[str, int]

(kind, n) for a finding's number such as 'D-2' or 'NC-1'.

Refused with ValueError: anything not a kind's prefix, a hyphen and a whole number from 1 ('D-0', 'd-1', 'D1', 'D-01'). TypeError for a value that is not a string.

next_number

next_number(entries: Iterable[Mapping[str, Any]], kind: str, issued: Mapping[str, int] | None = None) -> str

The number the next finding of kind takes: one past the highest of that kind entered, or ever issued (issued, the highest number by prefix, as issued_of reads it), so a number once given is never given again to another finding, even after the first is removed.

issued_of

issued_of(value: Any) -> dict[str, int]

The highest number issued of each kind, by prefix ({'D': 3}), as a register keeps it; empty for None. Refuses anything else with ValueError.

band_of

band_of(value: Any, what: str = 'band') -> list[float] | None

A band as [low, high] in Hz, or None for none.

Refused with ValueError: a count other than two, a number that is not finite, a negative frequency, or a low edge above the high one; with TypeError, anything but a sequence of numbers. Equal edges are one frequency.

clean_draft

clean_draft(value: Any) -> dict[str, Any] | None

A fact draft as stored on a finding: 'text' (required, not blank), 'source', 'run', 'channel' and 'band'. None for none. TypeError for anything but a mapping, ValueError for a field it does not hold or blank text.

clean

clean(entry: Mapping[str, Any]) -> dict[str, Any]

A finding as it is stored, every field present and checked.

entry holds 'number' (from which the kind is read) and any of 'kind' (which must agree with the number), 'run', 'channel', 'band', 'fact', 'cause', 'effect', 'approval', 'status' and 'draft'. Text is stripped; a missing field is empty.

Raises:

Type Description
ValueError

For a malformed number, a kind that disagrees with it, a band that is not two ordered, finite, non-negative frequencies, a status outside STATUSES, a malformed draft, or a field this module does not know. The message names the finding.

TypeError

When a text field is not a string, or a band or draft is not of its type.

read

read(entries: Any) -> list[dict[str, Any]]

A register as stored (a list of findings), each clean, in the order a report lists them: by kind, then by number. Refuses a number given twice (ValueError) and anything that is not a list (TypeError).

owed

owed(entry: Mapping[str, Any]) -> list[str]

The parts of a finding still owed, in order: each of fact, cause, effect and approval that is blank. A part is never filled for the author; "not determined" is a cause, and the author writes it.

declared

declared(text: str) -> set[str]

The kinds an author's words say there are none of: each kind whose NONE_SENTENCES sentence the words hold.

withdraw

withdraw(text: str, kinds: Iterable[str]) -> str

text with the none sentence of each kind in kinds taken out, and the white space it leaves tidied.

declaration

declaration(kinds: Iterable[str]) -> str

The none sentences of kinds, in the order of KINDS.

pair_records

pair_records(specification: Specification, measured: DataArray, channel: str) -> tuple[int, int]

(specification record, measured record) for channel, paired the way every comparison pairs them (compliance.matched_records, by DOF and quantity).

Refused with ValueError: a channel the two do not have in common (naming the channels they do), and a label that names two pairs (a DOF compared as two quantities), naming the quantities.

excursions

excursions(specification: Specification, measured: DataArray, spec_record: int = 0, measured_record: int = 0, *, pair: str = 'abort', band: Sequence[float] | None = None, scale_db: float | None = None) -> ExcursionReading

Where one measured record went outside one pair of limits.

Every cell of the comparison (compliance.judge, the same cells and the same scale the comparison figure and its readouts use) is judged against the pair's upper and lower limit. Neighboring cells out on the same side make one stretch, reported by its first and last measured line, its line count and its worst size: the cell's density against the limit's, in dB. With band (low, high in Hz), only cells reaching into it are read.

Parameters:

Name Type Description Default
specification (Specification, DataArray)

The pair, as a comparison figure draws it.

required
measured (Specification, DataArray)

The pair, as a comparison figure draws it.

required
spec_record int

Which record of each (pair_records finds them by channel).

0
measured_record int

Which record of each (pair_records finds them by channel).

0
pair str

'abort' or 'warning'.

'abort'
band (float, float)

The frequencies to read, in Hz.

None
scale_db float

The comparison's scale; resolved for the whole measurement (compliance.comparison_scale_db) when omitted, as compliance.compare_all resolves it.

None

Returns:

Type Description
ExcursionReading

The stretches, possibly none. No stretch is not a statement that the channel was inside its limits anywhere it was not judged: judged, low, high and unjudged say what was.

Raises:

Type Description
ValueError

A pair other than warning or abort, or one the specification does not carry; a pair the comparison refuses (different quantities, units declared on one side only, a banded measurement against a breakpoint curve), with its reason; a band that is not two ordered frequencies; nothing judged in the band (no data, no limit, or a band outside both); and a channel that holds no power where it was judged.